+ Reply to Thread
Results 1 to 5 of 5

Want to populate email fields FROM, TO, CC, Subject based on a named range

  1. #1
    Registered User
    Join Date
    08-23-2012
    Location
    Washington, United States
    MS-Off Ver
    Excel 2007
    Posts
    21

    Want to populate email fields FROM, TO, CC, Subject based on a named range

    Hello,

    I am trying to create an Outlook object email that poplates the fields in the email based on some named ranges I have in the Excel document. I have 2 sheets, Report and Distribution, the named ranges are on the Distribution sheet.

    Here is my code:
    Please Login or Register  to view this content.
    When I manually enter the email adresses in the FROM, TO, CC fields it works but when I try to use named ranges like this it doesn't.

    The named ranges contain the email addresses as well as the subject.

    Does anyone know what I'm doing worng?

    Thank you for the help!
    Last edited by mbhc77; 11-15-2012 at 04:44 PM.

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Want to populate email fields FROM, TO, CC, Subject based on a named range

    you will be btter off declaring your variables

    Please Login or Register  to view this content.
    Sean

  3. #3
    Registered User
    Join Date
    08-23-2012
    Location
    Washington, United States
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Want to populate email fields FROM, TO, CC, Subject based on a named range

    Thank you for the quick reply Sean.

    I updated my code to this and it still didn't work. On top of that now it's asking me if I want to save my document, whereas before I avoided that using my DontSaveClose Sub.

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Want to populate email fields FROM, TO, CC, Subject based on a named range

    Try this.
    It all works on mine as long as you have set a reference for outlook objects in tools,references.

    I cannot run it with your rng though. If i comment that out, this works perfectly.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-23-2012
    Location
    Washington, United States
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Want to populate email fields FROM, TO, CC, Subject based on a named range

    Thank you Sean! I will give that a try.

+ 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