NI Home > Community > NI Discussion Forums

LabVIEW

Showing results for 
Search instead for 
Do you mean 
Reply
Trusted Enthusiast
Trusted Enthusiast
Posts: 2,366
0 Kudos

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

Member
Arc.g
Posts: 23
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.

Trusted Enthusiast
Trusted Enthusiast
Posts: 2,366
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.

 

 

Member
Arc.g
Posts: 23
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).

Trusted Enthusiast
Trusted Enthusiast
Posts: 2,366
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

Active Participant
ben64
Posts: 766
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

Trusted Enthusiast
Trusted Enthusiast
Posts: 2,366
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.

Active Participant
ben64
Posts: 766
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

Member
Arc.g
Posts: 23
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.

 

 

Trusted Enthusiast
Trusted Enthusiast
Posts: 2,366
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.