Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Sending Outlook Message from Word VBA (VBA/Word, Outlook/2003)

    Please bear with me. This is my first venture into Outlook VBA.

    The attached zip file contains two modules as text files.

    "SendFmOL.txt" is Outlook code which appears to run properly. This code has been adapted to run from Word VBA--at least that was the intent. The fruits of my effort are provided in the "SendMail.txt" file.

    The code fails at line 130. I believe this is because line 110 doesn't seem to do anything.

    Will someone please critique my code? <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>
    Attached Files Attached Files
    Regards
    Don

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Sending Outlook Message from Word VBA (VBA/Word, Outlook/2003)

    Change line 110 from

    Set olMsg = olApp.MailItem

    to

    Set olMsg = olApp.CreateItem(0)

    0 is the value of the constant olMailItem that you used in Outlook. Since you appear to be using late binding, you cannot use a constant defined in the Outlook object library.

    Note: you should put line 120

    On Error GoTo ErrHandler

    before line 110 instead of after it.

  3. #3
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Sending Outlook Message from Word VBA (VBA/Word, Outlook/2003)

    Thank you for the speedy response Hans. My rebound question has already been answered by your post <!post=here,488173>here<!/post>.
    Regards
    Don

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Sending Outlook Message from Word VBA (VBA/Word, Outlook/2003)

    Nothing like a little foresight! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

Posting Permissions

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