Message 1 of 4
Opening and xls or xlsx file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm writing a tool to pull in data from an Excel file, and I am looking for some help understanding how to better control error situations. Currently I have these lines:
xlsFile = CreateOLEObject "Excel.Application"
openFileResult = xlsFile.application.Workbooks.open("C:\MyFile.xls")
(xlsFile.application.Worksheets("My Sheet")).Activate
How would I check for errors on any of these lines? Specifically, I keep getting errors on line 2 if I already have that sheet open in Excel. I see on the help file Workbooks.Open that there are options to open it as read only, but for the life of me I can't figure out a syntax in my Maxscript to pass the ReadOnly flag. Additionally, how do I check to see if the OLE application is ready after line 1 finishes, and how to I check to see if I was successful with the active sheet switch?
Thanks!
Ray