Link to home
Start Free TrialLog in
Avatar of aferia
aferia

asked on

Global Variables Reset when Dynamically Creating/Deleting or Changing OLEObjects

I have looked everywhere for a solution, but I sill cant find anything that explains the following problem:
Everytime I create/delete or change properties of an OLEObject in VBA it will reset all my variables.
I undetstand that VBA will reset variables on untrapped errors or when the code needs to me recompiled, but this does not seem to be the case for me since I am handling errors myself and I am not changing the code when the variables are lost.
Even a simple sniped like the following will reset my globals: "MyWorksheet" is the worksheet object, and "lblActualYearOrders" is an ActiveX label object created with the design tool from excell.
Please help.
MyWorksheetObject.lblActualYearOrders.Copy
MyWorksheetObject.Paste

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aferia
aferia

ASKER

Brilliant! I hadnt thought of it that way before. Too bad form objects are not as nice as OLE...
Thank you very much!