Forum Discussion
obaid_shirwani wrote:
Hi,
I had the below code working absolutely fine in TestComplete version 10. I have revisited it only to find it not working in version 12.
//No Issue
var book = Excel.Workbooks.Open(inputFileName);
As Sherlock Holmes once said, when you eliminate possibilities, whatever is left, however improbable, must be the case.
The above code you won't necessarily get an error if it fails. If it fails to open the workbook, it may just return a workbook object that has no Sheets or anything associated with it. So, it's possible that this is the cause of all your other issues. So, I'd start your investigation here... drop a breakpoint in to see if you are actually getting a valid "Workbook" object. If the object being returned is null, than "Sheets" would not be a recognized function.
Please upload the snapshot photo that you promised so we can help further, but I think I'd start first with investigating why the workbook isn't actually opening.
- obaid_shirwani7 years agoContributor
Hi Martin,
I had obviously checked that before posting. The returned Workbooks object holds the number of Sheets available in the file. So i think that is not the issue. I am attaching the screenshot for the object returned.
The visible class is throwing error. I assume it might be some version conflict or the driver issue.
Best regards,
Shirwani
- shankar_r7 years agoCommunity Hero
var sheet = book.Sheets(desiredSheetName)
Instead of this line, Can you try using below,
var sheet = book.Sheets.Item(desiredSheetName);
It works fine for me long time.
- obaid_shirwani7 years agoContributor
Hy Shankar,
I am unable to access 'book.Sheets' alone... it crashes here. How am i supposed to get past it?
Please view the attached images in previous posts and read the text again under "//Issue 02 (Intellisense popup)".
Thanks & regards,
Shirwani
Related Content
Recent Discussions
- 3 days ago