+ Reply to Thread
Results 1 to 2 of 2

Adjust code to pull excel data in subject line

  1. #1
    Registered User
    Join Date
    06-11-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    12

    Adjust code to pull excel data in subject line

    Hello,

    After going through forums I came up with the below code which works perfectly. It saves the worksheet as a PDF then attaches to an email. This is great as is; however icing on the cake would be if data from the worksheet could populate in the subject line.

    For example Subject would be "New Order for (B1)"

    Please advise

    Sub RDB_Worksheet_Or_Worksheets_To_PDF_And_Create_Mail()
    Dim FileName As String

    If ActiveWindow.SelectedSheets.Count > 1 Then
    MsgBox "There is more then one sheet selected," & vbNewLine & _
    "be aware that every selected sheet will be published"
    End If

    FileName = RDB_Create_PDF(ActiveSheet, "", True, False)

    If FileName <> "" Then
    RDB_Mail_PDF_Outlook FileName, "[email protected]", "New Subject Line", _
    "See the attached PDF for order " _
    & vbNewLine & vbNewLine & "Warm Regards", False
    Else
    MsgBox "Not possible to create the PDF, possible reasons:" & vbNewLine & _
    "Microsoft Add-in is not installed" & vbNewLine & _
    "You Canceled the GetSaveAsFilename dialog" & vbNewLine & _
    "The path to Save the file in arg 2 is not correct" & vbNewLine & _
    "You didn't want to overwrite the existing PDF if it exist"
    End If
    End Sub
    Last edited by maxutility; 08-15-2012 at 04:15 PM. Reason: David solved this

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

    Re: Adjust code to pull excel data in subject line

    Please use code tags around code for easy reading. It's the hash mark in message editor menu.

    In the code that actually sends the email, you should have a
    Please Login or Register  to view this content.
    Just change that to
    Please Login or Register  to view this content.
    Change the worksheet and range to suit.
    David
    (*) Reputation points appreciated.

+ 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