05-14-2012 09:07 AM - edited 05-14-2012 09:07 AM
The attached VI creates a new Excel workbook, select Sheet3, and then saves the workbook.
You'll notice when you open the file, that Sheet3 is "open".
05-14-2012 09:13 AM
Yes, that works. I need to be able to read the 'workbook.activesheet' property and close the reference, however.
05-14-2012 09:18 AM
I am not sure what you mean?
You choose the worksheet you want to use, write to/read from it, and close the reference.
05-14-2012 09:24 AM
This is just a basic example. I need to be able to read the Workbook.Activesheet property for the rest of the legacy code to work. There are a ton (100+) of legacy VI's that depend on this to work. We do some fancy stuff in excel, and it's surprising to suddenly have something so basic stop working.
What makes this peculiar is that it was working flawlessly for the better part of a decade. I have the VI's from 2004 and I've inspected the changelogs, which show no changes to the actual wiring since the beginning of time (or our svn repo, as you will).
05-14-2012 09:32 AM
@LVSteve wrote:
This is just a basic example. I need to be able to read the Workbook.Activesheet property for the rest of the legacy code to work. There are a ton (100+) of legacy VI's that depend on this to work. We do some fancy stuff in excel, and it's surprising to suddenly have something so basic stop working.
What makes this peculiar is that it was working flawlessly for the better part of a decade. I have the VI's from 2004 and I've inspected the changelogs, which show no changes to the actual wiring since the beginning of time (or our svn repo, as you will).
You don't know how to take the Workbook refnum created with the Workbooks.Add and use that refnum along with ActiveX Property Node to get the ActiveSheet?
Everything is based on Microsoft's Excel Object Model. Read up on it at http://msdn.microsoft.com/en-us/library/bb149081%28v=office.12%29
05-14-2012 09:32 AM - edited 05-14-2012 09:36 AM
Have you probe the error wires to see exactly where the error occurs. Using the code in your first post I moved the close Wokbooks reference just before the application quit method. I found that what is causing the error in my case is value 51 connected to the fileformat input. I disconnect it and it worked fine after that.
Ben64
05-14-2012 09:36 AM
He doesn't actually get an error.
He says that there is an Excel refnum that isn't properly closed which causes Excel to remain open.
05-14-2012 09:37 AM
05-14-2012 09:40 AM - edited 05-14-2012 09:42 AM
I'm no stranger to MSDN docs, thank you.
You are conflating the issue. Adding a worksheet is quite different and necessarily seperate from querying excel as to what the current activesheet is, and getting its reference.
I suppose I should attach another example.
05-14-2012 09:41 AM
My VI is NOT adding a worksheet.
You clearly have no idea what I am talking about.