+ Reply to Thread
Results 1 to 7 of 7

Opening a new outlook message via VBA

  1. #1
    Registered User
    Join Date
    06-12-2009
    Location
    Maryland
    MS-Off Ver
    Excel 2003
    Posts
    1

    Opening a new outlook message via VBA

    All-

    I am trying to create a command button in Excel that when clicked, it will open up a new Outlook email message, input a certain address in the To: field, and input a specific Subject. The following is the code that I found online earlier today but it does not work when I paste it into the VBA editor.
    Please Login or Register  to view this content.
    Now, the fact that it is getting an error could be my mistake since I have never created a VBA button before. Is there a basic crash course I can review for doing this and for inputting the code that is needed or can someone summarize it for me. Thank you for all of your help!
    Last edited by Leith Ross; 06-12-2009 at 08:51 PM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Opening a new outlook message via VBA

    Hello ea2004,

    To make your posts easier to read, copy, and edit please wrap your code. I did it for you this time. Here is how you can do

    it next time.

    How to wrap your Code
    1. Select all your code using the mouse.
    2. Click on the # icon on the toolbar in the Message window. This will automatically wrap the text you selected with

    the proper Code tags to create a Code Window in your post.

    3. You can also do this manually by placing the tags
    [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] at the end of the line.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    05-22-2009
    Location
    Shirland, IL
    MS-Off Ver
    Excel '00 & '03
    Posts
    51

    Re: Opening a new outlook message via VBA

    Try this:

    Please Login or Register  to view this content.
    Just open your visual basit editor (alt-f11), paste it into a new module (insert > Module). Then on your workbook create a new button from the forms toolbar and apply the macro send mail to it. should work fine. did for me.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Opening a new outlook message via VBA

    just on an aside on the off chance it's of interest you can achieve the same thing with a hyperlink, ie entering the below into a cell and subsequently clicking it will generate the requisite dialog.

    mailto:[email protected]&subject=Hello%20World

    (the %20 will give you a space)

  5. #5
    Forum Contributor
    Join Date
    06-24-2009
    Location
    SCOTLAND
    MS-Off Ver
    Excel Version 2108
    Posts
    144

    Re: Opening a new outlook message via VBA

    I have tried fire-water's macro with a degree of success, however the message entered doesn't appear anywhere on the email!
    The Input Box appears and allows a message to be written, then the outlook message opens up with the selected email address but no sign of the message from the input box!
    You've probably gathered I'm very new to this and require more explanation of each step. Any help would be much appreciated.
    I am using Excel 2007.

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Opening a new outlook message via VBA

    Try changing this line:
    Please Login or Register  to view this content.
    to this:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  7. #7
    Forum Contributor
    Join Date
    06-24-2009
    Location
    SCOTLAND
    MS-Off Ver
    Excel Version 2108
    Posts
    144

    Re: Opening a new outlook message via VBA

    Tried this but no difference whatsoever!
    Code:

    objMsg.Body = StrMsg
    Thanks for the suggestion anyhow.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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