user-defined type not defined

justme

Well-known Member
Joined
Aug 26, 2002
Messages
729
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?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
are the references installed the same on both machines

this might point the way
 
Upvote 0
Please explain further. Excel help mentioned references, but I'm not sure where the reference dialog box is?
 
Upvote 0
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.
 
Upvote 0
my work systems 2003 / 2007 often deletes the references for DAO and something else. I'd like to know more about the open event
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,763
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