Reference class instantiated in ThisWorkbook module

tinkythomas

Active Member
Joined
Dec 13, 2006
Messages
432
Hi,
I have a class that I instantiate in the Workbook_Open event in the ThisWorkbook module. How do I properly reference it outside the module? I have tried MyClass.Property syntax but intellisense doesn't pop up with the property name after I type the period like it should do. This leads me to believe that I'm not referencing properly?

Any help would be appreciated.

Regards,
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
The class variable should be declared as Public in a standard code module.
 
Upvote 0
The class variable should be declared as Public in a standard code module.

Sorry, I don't follow? Your saying I need to declare the class twice, even though it's been instantiated in the ThisWorkbook module?

Thanks for the reply.
 
Upvote 0
An instance of a class is assigned to an object variable. If that variable is to be accessed outside the module where the instance is created, then the class variable must be Public, which means it has to be declared in a standard code module.

If that's not clear, then post your code.
 
Upvote 0
Thank you very much, sorry for the misunderstanding! I was declaring the class variable inside the Workbook_Open sub instead of the declarations section of a standard module.

All is working as expected now!

Thanks again,
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,750
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top