Hi all, is it possible to declare a variable in ThisWorkbook and use the variable in module procedures? Basically i want to create a global variable somewhere that allows me to use the variable in events, modules and procedures. i'm using excel 2003
It's true that you can declare a public variable in an object module (sadly, in my opinion). I think, however, that this goes against the object model paradigm, goes agains one of the fundamental characteristics of object oriented design, that is Encapsulation. In my opinion it's not good practice to declare public variables in a class. I go even as far as to say that it should even not be allowed by the syntax.
I would agree completely but I thought that getting into Property procedures was probably a bit OTT for this discussion.
As a return bit of dogma, public variables should be avoided if at all possible.