PDA

View Full Version : Sleeper: Memory Issue



Maka
05-02-2005, 09:44 AM
Hi, i have no way of explaining this clearly so i will try my best.
I developed a VBA add-on that works with a userform. I access the userform from a button created in workbook_open code. The thing is the userform can read data form the sheets and create a structure ("type ...."). from the userform i can print some reports and modify the data to change the reports. Sometimes, moslty after printing a report, if I close the userform and then call it again form the button, all the public variables i had created and read before is lost and also all the changes i created earlier. Is there any way the public variables "survive" several closing and openings of the userform?
hope its clear enough.

Bob Phillips
05-02-2005, 09:51 AM
Where are the piublic variab les defined, in a normal code module, or in the userform class module?


How do you clode the form, with Unload or Hide?

Killian
05-02-2005, 10:01 AM
If you declare the variables you need as Public in a standard module they will available while the project is active.
As xld indicates,you could also have varibles declared in the user form and then hide/show the userform from the button (load on Workbook_Open and unload on Workbook_close.) This keeps it in memory so if it's used often there may be advantage to this.

BlueCactus
05-02-2005, 12:38 PM
What about saving the variables to a file on disk, and reading them back the next time?