07-12-2012 11:36 AM
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
Solved! Go to Solution.
07-21-2012 10:41 AM - edited 07-21-2012 10:42 AM
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.
07-21-2012 12:22 PM - edited 07-21-2012 12:25 PM
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?
07-23-2012 10:02 AM
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!