+ Reply to Thread
Results 1 to 9 of 9

Need help adding the file name as the subject in an email sent from Excel

  1. #1
    Forum Contributor rkjudy's Avatar
    Join Date
    03-31-2009
    Location
    Longview, TX
    MS-Off Ver
    MS Office 2010
    Posts
    239

    Need help adding the file name as the subject in an email sent from Excel

    I have a workbook that has a macro that creates a PDF of a certain sheet and attaches it to an email and opens Outlook ready for sending. Then, all i have to do is add the email address of the recipient and send it. As it is coded now, the Subject of the email is simply "New Equipment Quote". I would like for the Subject to be "New Equipment Order for" + Filename. For example, if the filename were ABC Company, the Subject would be "New Equipment Order for ABC Company". Here is my current code.

    Please Login or Register  to view this content.
    Can someone show me how to add the filename to the end of the Subject?

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Need help adding the file name as the subject in an email sent from Excel

    Please Login or Register  to view this content.
    David
    (*) Reputation points appreciated.

  3. #3
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Need help adding the file name as the subject in an email sent from Excel

    Hi rk,

    Try the following (your other routines were untouched - you still need them):
    Please Login or Register  to view this content.

    Lewis
    Last edited by LJMetzger; 05-08-2014 at 02:32 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    09-01-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    324

    Re: Need help adding the file name as the subject in an email sent from Excel

    --- Solved ---
    Last edited by playaller; 05-08-2014 at 02:39 PM. Reason: Already Solved


    Shelton A.
    If Helpful, Add Reputaion!

  5. #5
    Forum Contributor rkjudy's Avatar
    Join Date
    03-31-2009
    Location
    Longview, TX
    MS-Off Ver
    MS Office 2010
    Posts
    239

    Re: Need help adding the file name as the subject in an email sent from Excel

    The first solution provided above did cure the problem, but I guess I left out another key piece of information. I don't want to use a static FileName. I want the FileName to the be the name of the workbook at that time. So I guess I will need to adjust the statement that defines the FileName as static "New Equipment Quote" to where it will make the FileName the current name of the workbook. For example, if the name of the workbook at the time the email is created is "ABC Company", I want the FileName to be "ABC Company", so that the Subject will be "New Equipment Order for ABC Company". Any help?

  6. #6
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Need help adding the file name as the subject in an email sent from Excel

    How about...
    Please Login or Register  to view this content.
    Last edited by Tinbendr; 05-09-2014 at 02:33 PM.

  7. #7
    Forum Contributor rkjudy's Avatar
    Join Date
    03-31-2009
    Location
    Longview, TX
    MS-Off Ver
    MS Office 2010
    Posts
    239

    Re: Need help adding the file name as the subject in an email sent from Excel

    The FileName is changed (through another routine) every time the workbook is used. So, I don't want a fixed FileName. I want the FileName to be the CURRENT name of the workbook. Therefore the Subject will also also be correct. What do you think?

  8. #8
    Forum Contributor rkjudy's Avatar
    Join Date
    03-31-2009
    Location
    Longview, TX
    MS-Off Ver
    MS Office 2010
    Posts
    239

    Re: Need help adding the file name as the subject in an email sent from Excel

    When using the code above:

    Please Login or Register  to view this content.
    I get a Run-time error '438':
    Object doesn't support this property or method.

    Can someone help me with this issue?

  9. #9
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Need help adding the file name as the subject in an email sent from Excel

    Try replacing 'ActiveSheet.Path' with 'ActiveWorkbook.Path'.

    Lewis

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. vba pull data from outlook body of email through email or subject of mail into excel
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-01-2014, 04:37 AM
  2. Email Hyperlink Adding Body/Subject Text
    By jpmorgan123 in forum Excel General
    Replies: 1
    Last Post: 05-12-2013, 12:41 PM
  3. export outlook 2007 email into excel with subject and body of email
    By akulka58 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2013, 02:37 PM
  4. Email Macro: File Name Is Subject
    By SamuelT in forum Excel General
    Replies: 3
    Last Post: 11-10-2006, 11:54 AM
  5. Subject line in email defaults to workbook file name.
    By swellett in forum Excel General
    Replies: 2
    Last Post: 03-17-2006, 12:40 PM

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