VBA – Working with Classes from the Immediate Window

If you have some experience with VBA, you already have enjoyed the usefulness of the immediate window – it simply does anything! Anyway, when you try to enter a subroutine, a method or a function, declared in class, you receive an unpleasant mistake, telling you something about a class, which is not defined:



How we can resolve this issue? The answer is quite simple actually – declare the class in the immediate window like this:

Then, when you would like to refer to any function or property of the class, you would get an answer (marked with red in the screenshot):



So, last but not least, I will give the code of the example. It is taken from one good example in StackOverflow. It consists of two Class Modules and one Regular Module.

This is how it looks like:

That’s all!

Tagged with: , ,