+ Reply to Thread
Results 1 to 10 of 10

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

  1. #1
    SupperDuck
    Guest

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

    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,



  2. #2
    Norman Jones
    Guest

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

    Hi SupperDuck,

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


    ---
    Regards,
    Norman



    "SupperDuck" <[email protected]> wrote in message
    news:[email protected]...
    > 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,
    >
    >




  3. #3
    SupperDuck
    Guest

    Re: "User-defined type not defined" error when trying to send e-ma

    Dear Norman,

    Can you please how can i make this?

    I do not know to add a reference..

    Thanks,

    "Norman Jones" wrote:

    > Hi SupperDuck,
    >
    > You need to add a reference to the Microsoft Outlook xxx Object Library.
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "SupperDuck" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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,
    > >
    > >

    >
    >
    >


  4. #4
    SupperDuck
    Guest

    Re: "User-defined type not defined" error when trying to send e-ma

    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...

    "Norman Jones" wrote:

    > Hi SupperDuck,
    >
    > You need to add a reference to the Microsoft Outlook xxx Object Library.
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "SupperDuck" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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,
    > >
    > >

    >
    >
    >


  5. #5
    Bob Phillips
    Guest

    Re: "User-defined type not defined" error when trying to send e-ma

    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)

    "SupperDuck" <[email protected]> wrote in message
    news:[email protected]...
    > 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...
    >
    > "Norman Jones" wrote:
    >
    > > Hi SupperDuck,
    > >
    > > You need to add a reference to the Microsoft Outlook xxx Object Library.
    > >
    > >
    > > ---
    > > Regards,
    > > Norman
    > >
    > >
    > >
    > > "SupperDuck" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > 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,
    > > >
    > > >

    > >
    > >
    > >




  6. #6
    Norman Jones
    Guest

    Re: "User-defined type not defined" error when trying to send e-ma

    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)


    ---
    Regards,
    Norman


    "SupperDuck" <[email protected]> wrote in message
    news:[email protected]...
    > 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...
    >




  7. #7
    SupperDuck
    Guest

    Re: "User-defined type not defined" error when trying to send e-ma

    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...


    "Norman Jones" wrote:

    > 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)
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    > "SupperDuck" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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...
    > >

    >
    >
    >


  8. #8
    Norman Jones
    Guest

    Re: "User-defined type not defined" error when trying to send e-ma

    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.


    ---
    Regards,
    Norman



    "SupperDuck" <[email protected]> wrote in message
    news:[email protected]...
    > 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...




  9. #9
    Bob Phillips
    Guest

    Re: "User-defined type not defined" error when trying to send e-ma

    Why don't you use late binding then. See
    http://xldynamic.com/source/xld.EarlyLate.html

    --
    HTH

    Bob Phillips

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

    "SupperDuck" <[email protected]> wrote in message
    news:[email protected]...
    > 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...
    >
    >
    > "Norman Jones" wrote:
    >
    > > 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)
    > >
    > >
    > > ---
    > > Regards,
    > > Norman
    > >
    > >
    > > "SupperDuck" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > 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...
    > > >

    > >
    > >
    > >




  10. #10
    Trefor
    Guest

    Re: "User-defined type not defined" error when trying to send e-ma

    Bob,

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


    "Bob Phillips" wrote:

    > Why don't you use late binding then. See
    > http://xldynamic.com/source/xld.EarlyLate.html
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > (replace somewhere in email address with gmail if mailing direct)
    >
    > "SupperDuck" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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...
    > >
    > >
    > > "Norman Jones" wrote:
    > >
    > > > 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)
    > > >
    > > >
    > > > ---
    > > > Regards,
    > > > Norman
    > > >
    > > >
    > > > "SupperDuck" <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > > 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...
    > > > >
    > > >
    > > >
    > > >

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1