Function to export App data in Excel is throwing VBscriptRunTimeError on TestCompleteVersion12
- 10 years ago
What is the error message text?
You say it throws and error, but haven't said what the error is! Kind of hard to fix a problem when you don't know exactly what it is! :smileywink:
Looking at your code ......
You declare an Excel object.
Then you add a workbook to it.
Then you save it. (Well, SaveAs, but same thing)
You then re-open it - which I don't think you need to do. It's already open.
Then you try and assign the two sheets.
So ...
Obvious thing - your Excel file does have more than one sheet right? And one of those worksheets is called "Sheet2"?
Default behaviour for Excel when you create a new workbook (manually) is that it is created with three sheets. Not sure if this is the case for all versions or if it's done through scripts?
Given that you save(as) the new workbook, then immediately re-open it, without closing the original file first, where does this leave Excel? Do it load a copy?, not load the second version?, I'm not sure what it'll do exactly. But you should be able to see.