VBA personal workbook class module - User-defined type not defined

Combat Womble

New Member
Joined
Nov 18, 2015
Messages
30
Hello everyone,

I have a class module in my personal work book. I am trying to instansitate this object from a module in a seperate workbook and I keep getting a User-defined type not defined error.
I have:
set the class to private and publicnotcreatable settings.
added Microsoft Scripting Runtime library
used the following syntax (NameMap is the name of the class)
VBA Code:
Dim nameChecker As NameMap
Dim nameChecker As Object
Dim nameChecker As Varient
Set nameChecker = New NameMap
Dim nameChecker As New NameMap
If I copy the class code into the worksheet (not personal workbook) it will run.

The reason I want this to be in my personal workbook is that the dictionary it holds is long and requires updating every so often. One place one update.

I am sure I am doing something simple wrong.

Please advise me

Combat Womble
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
the type NameMap MUST be defined in the vba REFRENCES. Alt-F11 (vbe) , tools, references,
then pick the ocx, or dll that is used for nameMaps.

you can also sometimes 'cheat' by just declaring nameChecker var as variant
Dim nameChecker

then let the late binding decide what it will become:
Set nameChecker = New NameMap

but if it's an obscure object you will need the REFERENCE loaded.
 
Upvote 0
Solution
You've also misspelled Variant. :)
 
Upvote 0
Thank you ranman256
I got there in the end.

Info for anyone who views this thread looking for answers (This is what i did - its might not be the best way!)
1. I went to tools -> references
2. I found two available references called VBAProject
3. Cancelled
4. Changed the name of my personal.xlsb using the Project - VBAProject window to masterMacrosAndClasses
5. I went to tools -> references
6. I found a reference called masterMacrosAndClasses
7. ticked the box and hit OK

RoryA - My question as been answered, I now have a follow on issue (I get a Invalid use of New Keyword error) am I right in thinking I must now raise another question on the forum?

Thanks again
Combat Womble
 
Upvote 0
Ideally, yes please.
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,821
Members
449,049
Latest member
cybersurfer5000

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