LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Closing ActiveX References

Solved!
Go to solution

Hi All,

 

I am just starting to work with ActiveX controls.  The attached graphic shows a loop that opens different Excel worksheets within a workbook, based on user selection.

 

My questions are:

 

1.  Does the "Variant to Data" function create a new refnum each time it runs?  If so, then I would have to move the associated "Close Reference" function inside the loop, yes?

 

2.  Is there a better way to select different worksheets?

 

Any help would be greatly appreciated.

 

Thanks,

 

FB

 

ActiveX Loop.png

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 1 of 4
(2,810 Views)

I am sure some here will correct me if I am wrong, but here is goes.

 

1. The information on a wire is only stored temporally and is written over each time through the loop. So no it does not create a new refnum each time, only writing over the only one so you should only have to close it at the end.

 

2.Nope.

0 Kudos
Message 2 of 4
(2,758 Views)
Solution
Accepted by topic author diarmaede

Yes, you should close the reference inside the event, immediately after you're done using it.  You could leak references the way you're doing it now.

 

I don't see any problem with that method of selecting a worksheet - is there some reason you don't like it?

 

EDIT: Also, is there some reason you have the Excel._Worksheet type as a control rather than a constant?

Message 3 of 4
(2,750 Views)

I started using "Activate" rather than "Select" to select the worksheet.  Looks a bit more compact on the screen and seems to do the same thing.

 

I am using a control instead of a constant because that's the way it was set up in the example.  I never even thought of using a constant, but that does make a great deal of sense.  Thanks!

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 4 of 4
(2,726 Views)