From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Activex Excel Automation: the Missing Handle

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
(893 Views)

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
(885 Views)

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
(880 Views)

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
(878 Views)

@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
(871 Views)

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

0 Kudos
Message 16 of 62
(868 Views)

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
(865 Views)

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

 

Ben64

0 Kudos
Message 18 of 62
(863 Views)

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
(859 Views)

My VI is NOT adding a worksheet.

 

You clearly have no idea what I am talking about.

 

 

0 Kudos
Message 20 of 62
(856 Views)