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

Combat Womble

New Member
Joined
Nov 18, 2015
Messages
27
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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
1,977
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.
 
Solution

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,696
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
You've also misspelled Variant. :)
 

Combat Womble

New Member
Joined
Nov 18, 2015
Messages
27
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
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,696
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Ideally, yes please.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,566
Messages
5,637,085
Members
416,956
Latest member
mitzhaki

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
Top