"User-defined type not defined" error when trying to send e-mail

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear all,

I want to send e-mail via a list in a excel document so i try to write a
macro.
In my macro, for outlook i use the code;

Dim OutApp As New Outlook.Application
Dim OutMail As Outlook.MailItem

Set myOlApp = New Outlook.Application
Set myItem = myOlApp.CreateItem(olMailItem)


But i got an error " user-defined type not defined"

I selected the

Visual basic for applications
Microsoft Excel 11.0 Object library
OLE Automation
Microsoft Office 11.0 Object Library
Microsoft DAO 3.6 Object Library.


So i wonder where the problem is and need your help in this situation...

Kind regards,
 
Hi SupperDuck,

You need to add a reference to the Microsoft Outlook xxx Object Library.
 
Dear Norman,

Can you please how can i make this?

I do not know to add a reference..

Thanks,
 
Ah sorry, adding the same things.

In my first post i forgot to write that there was Microsoft Outlook 11.0
Object library .

There is it but still have problem...
 
Are you sure about that (Tools>References), as that is exactly the error
that you get if you don't set a reference to the Outlook type library.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Hi SupperDuck,

Providing I had set a reference to the Microsoft Outlook Object Library (In
the VBE, Tools | References), I could not repoduce your error.

Incidentally, but with no bearing on your problem, perhaps your code should
read:

Dim myOlApp As Outlook.Application
Dim myItem As Outlook.MailItem

Set myOlApp = New Outlook.Application
Set myItem = myOlApp.CreateItem(olMailItem)
 
Hello Norman,

Thank your for replies. The problem was, when two Excel files are opened and
i select the Microsoft outlook object library, there is a probability of not
been seen by one of the files.

Is there a way for selecting these libraries, in all excel files including
the new opened ones?

Thanks...
 
Hi SupperDuck,

References are specific to a given workbook.

If you wish to add a reference to all new workbooks, open the workbook
template ( in my case, Book.xlt in my XLSTART folder), add the required
reference(s), save and close the template.
 
Bob,

Is it possible to check if Outlook is actually installed (via VBA) without
running into the Reference error?
 

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

Back
Top