D
David McCulloch
QUESTION:
I tried to define global variables in a module with the Public statement.
Unfortunately, their values were eventually lost (possibly because I clicked
Excel's debug reset button or because the application that I inherited uses
an End statement?). Whatever the cause, what is a good way to reinitialize
them? I have a function to do that, but when would I run it? I already call
it from my workbook's open event. Is there an event that runs immediately
after Public variables are lost or before any other event would run? It's a
large application, so I would not want to start every function with a check
of my public variables.
OPTIONAL READING:
Normally, I would use Public Const statements to declare my constants, but
this is a multi-workbook application where workbooks must be able to access
one another. Today, each workbook has each other's constants embedded
within it. When one workbook's constants are changed, all other workbooks
must be updated accordingly and released along with it. To simplify, I want
to create a sheet named GBL in each workbook to hold that workbook's
constants (column-1 would be variable name; column-2 would be variable
value). When one workbook needed to access another workbook, the first
workbook would read the second workbook's GBL sheet and its constants (or at
least the ones that the first program needed). This way, when I must change
a workbook's constants, I would not have to update and release all other
workbooks.
Dave
I tried to define global variables in a module with the Public statement.
Unfortunately, their values were eventually lost (possibly because I clicked
Excel's debug reset button or because the application that I inherited uses
an End statement?). Whatever the cause, what is a good way to reinitialize
them? I have a function to do that, but when would I run it? I already call
it from my workbook's open event. Is there an event that runs immediately
after Public variables are lost or before any other event would run? It's a
large application, so I would not want to start every function with a check
of my public variables.
OPTIONAL READING:
Normally, I would use Public Const statements to declare my constants, but
this is a multi-workbook application where workbooks must be able to access
one another. Today, each workbook has each other's constants embedded
within it. When one workbook's constants are changed, all other workbooks
must be updated accordingly and released along with it. To simplify, I want
to create a sheet named GBL in each workbook to hold that workbook's
constants (column-1 would be variable name; column-2 would be variable
value). When one workbook needed to access another workbook, the first
workbook would read the second workbook's GBL sheet and its constants (or at
least the ones that the first program needed). This way, when I must change
a workbook's constants, I would not have to update and release all other
workbooks.
Dave