user-defined type not defined

justme

Well-known Member
Joined
Aug 26, 2002
Messages
722
I have two "identical" workbooks being completed by two different people. My email code works in one, but not another. I copied the code from the workbook that works to the workbook that doesn't and I still get the compile error: User-defined type not defined.

Excel help isn't helping. The code stops in the second line below:

Dim FName As String
Dim VBComp As VBComponent (here, this line is hi-lited)
Dim wbnew As Workbook
Dim x As String

Thoughts?
 

Some videos you may like

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

mole999

Moderator
Joined
Oct 23, 2004
Messages
10,524
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
are the references installed the same on both machines

this might point the way
 

justme

Well-known Member
Joined
Aug 26, 2002
Messages
722
Please explain further. Excel help mentioned references, but I'm not sure where the reference dialog box is?
 

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
23,906
VBComponents is a data type that requries the Microsoft Visual Basic for Applications Extensibility library be referenced.
A quick fix would be to use
Code:
Dim VBComp As Object

But there may be other problems later, from that same missing library, in which case an Open event that automaticaly opens that reference library may be needed.
 

mole999

Moderator
Joined
Oct 23, 2004
Messages
10,524
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows

ADVERTISEMENT

my work systems 2003 / 2007 often deletes the references for DAO and something else. I'd like to know more about the open event
 

mole999

Moderator
Joined
Oct 23, 2004
Messages
10,524
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
Please explain further. Excel help mentioned references, but I'm not sure where the reference dialog box is?

A number of ways into VBA, i use right click on a tab and then view code, into the VBA window.

Then Tools > references

and see what is listed on both machines
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,218
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Does the code actually use the variable causing the problem?

If all it's meant to do is email then I wouldn't think you would need to use something like VBComponent.
 

justme

Well-known Member
Joined
Aug 26, 2002
Messages
722
Thank you Mole9999 & mikerickson-

I checked the references and both computers are the same. I ended up duplicating the good workbook, erasing the information and copying the info from the bad workbook into the good workbook. The code works fine now. Wierd.
 

justme

Well-known Member
Joined
Aug 26, 2002
Messages
722
In one part of the code it is sending the original wb to me and in the other part of the code it is sending a new wb to the supervisor which is a selected area of one of the pages in the wb.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,517
Messages
5,596,619
Members
414,081
Latest member
Subaru_Steve

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