Showing results for 
Search instead for 
Did you mean: 
Reply

Activex Excel Automation: the Missing Handle

Re: Activex Excel Automation: the Missing Handle

[ Edited ]

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".

0 Kudos
Message 11 of 62 (272 Views)
Reply
0 Kudos

Re: Activex Excel Automation: the Missing Handle

Yes, that works.  I need to be able to read the 'workbook.activesheet' property and close the reference, however.

0 Kudos
Message 12 of 62 (264 Views)
Reply
0 Kudos

Re: Activex Excel Automation: the Missing Handle

I am not sure what you mean?

 

You choose the worksheet you want to use, write to/read from it, and close the reference.

 

 

0 Kudos
Message 13 of 62 (259 Views)
Reply
0 Kudos

Re: Activex Excel Automation: the Missing Handle

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).

0 Kudos
Message 14 of 62 (257 Views)
Reply
0 Kudos

Re: Activex Excel Automation: the Missing Handle


Arc.g 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

0 Kudos
Message 15 of 62 (250 Views)
Reply
0 Kudos

Re: Activex Excel Automation: the Missing Handle

[ Edited ]

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

--------------------------------------------------
The best way to say thanks is to give kudos!
0 Kudos
Message 16 of 62 (247 Views)
Reply
0 Kudos

Re: Activex Excel Automation: the Missing Handle

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.

0 Kudos
Message 17 of 62 (244 Views)
Reply
0 Kudos

Re: Activex Excel Automation: the Missing Handle

You're right, but I'm getting an error when I run the snippet (LV2009 Excel2003)

 

Ben64

--------------------------------------------------
The best way to say thanks is to give kudos!
0 Kudos
Message 18 of 62 (242 Views)
Reply
0 Kudos

Re: Activex Excel Automation: the Missing Handle

[ Edited ]

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.

 

 

0 Kudos
Message 19 of 62 (238 Views)
Reply
0 Kudos

Re: Activex Excel Automation: the Missing Handle

My VI is NOT adding a worksheet.

 

You clearly have no idea what I am talking about.

 

 

0 Kudos
Message 20 of 62 (235 Views)
Reply
0 Kudos