Compiler error

L

Lodewijk Olthof

On my form I have a button to email a document from disc. The code behind
this button is:

Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

With objEmail
.To = (e-mail address removed)
.Attachments.Add strDocument
.Send
End With

When I push the button, I get the following (translated) error message:
(Compileerfout: Een door de gebruiker gedefinieerd gegevenstype is niet
gedefinieerd)
A by the user defined gegevenstype (I don't know the right word, but it's
the type for boolean, string, etc.) is not defined.

What do I have to do to correct this
 
J

jb33

I'm a 3 day newbie but it looks like the message I got
without a reference to DAO. With a code window open, not
in debug mode, go to tools, references, select DAO 3.6
and unselect ADO 2.x - but maybe you need a reference to
outlook ...
jb
 
L

Lodewijk Olthof

Sorry, that's obviously interesting to know.

The error occurs on the line with: Dim objOutlook As Outlook.Application
 
K

Ken Snell

I am guessing that you don't have a reference set to Outlook.

However, by using CreateObject, you don't need to Dim objOutlook that way.
Replace that line of code with this:

Dim objOutlook As Object


That will use late binding and you won't need a reference to be set.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top