07-21-2011 01:24 PM
I need to open two existing excel documents and store data using active X. I'm able to open a single excel document. When I try opening two, I get an error stating that it's already opened.
07-21-2011 01:45 PM
Hi joeG,
Yes, you can open 2 Excel documents using ActiveX calls. It sounds like you are trying to open two references to Excel, but you can use the same Excel reference to open multiple documents. Once you have opened the Excel application reference you can use the Workbooks property to open as many individual workbooks as you would like, and work with them individually. See attached VI, let me know how it works out for you.
Thanks
Eric
07-21-2011 01:48 PM
Thanks Kudos. I will try it out. I am running LabView 8.2.
07-21-2011 01:51 PM
No prob, here is the VI in 8.2 (previous one was 8.5).
Thanks
Eric
07-22-2011 10:59 AM
Thanks. That makes sense. How would you open and close sheets in both files?
07-22-2011 11:33 AM
Opening a worksheet is done by accessing the Worksheets property of the Workbook reference and, using an invoke node, call the method Item and pass to it the index of the worksheet you want to open. What is returned is a variant, and you need to convert this variant to the Excel._Worksheet class to then work with it as a worksheet. From here you can read, write, etc.
Do you have the Report Generation toolkit for Microsoft Office? If you do, it could be a lot easier to work with depending on what you are trying to accomplish...
Eric
07-22-2011 03:04 PM
Thanks Eric. That works fine. One of those files will be used to save data during a script file run. Is it possible to save a file and start a new one everytime I run the script. Running the script file is part of the overall program. It allows me to save portions of the data.