Compile error: User-defined type not defined

bwalk037

Registered User.
Local time
Today, 05:22
Joined
Mar 20, 2009
Messages
22
I just wanted to submit this solution out here so in case someone runs into the same error they will know how to fix it.

I have a module that sends emails out of Outlook based on information that is pulled into Access via an Excel worksheet. When I went from Access 2003 to Access 2010 I was getting the error: "Compile error: User-defined type not defined" when trying to run that particular module.

I found the solution online and I just wanted to pass it along.

To fix this error you will need to:

1) Open the Module
2) Go to Tools> References
3) Select Microsoft Outlook xxx Object Library

Save module.
 
An even better fix is to NOT set a reference to begin with and instead use LATE BINDING so then it matters not which version you have installed. So your code would need to use

Dim ol As Object

instead of

Dim ol As Outlook.Application

And then you would call it using

Set ol = CreateObject("Outlook.Application")

and so on for the rest of the objects. Late binding is great for making sure that you do not have version issues, especially if you develop in a later version and need to pass it back to someone with an earlier version.
 
Nice tip. I will have to try that out! Thank you.
 

Users who are viewing this thread

Back
Top Bottom