replace subject line generated by converting a word document to PDF and sending it to an email

Status
Not open for further replies.

Carla100

New Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server
I hoping to find a solution to my issue. I will be in a word document and utilize the "Email as a PDF Attachment" button I've stuck up on my quick access tool bar. It nicely generates an email all ready to go with the PDF attachment. unfortunately, it sticks something in the subject line. I need to replace that with some standard information that I have to put in all those emails. Emails generated in this particular way don't want to let me run anything without having saved it and closed it. When I reopen it I can take some action. Has anyone a script that would save, close open and replace whatever the generated subject line is with some standard line I create? It is over my head and I'm not finding exactly what I need. I'm hoping it exists!
 
Will you always save the file to the same location? I have a macro - this saves the pdf in the same location as the docx file, but as long as we have a filename and a path, it can go anywhere.


Code:
Sub SaveAndSendPDF()
 Dim olApp 'As Outlook.Application
 Dim olItem 'As Outlook.MailItem
 
 Dim dlgSaveAs As FileDialog
  Dim strPath As String
  Dim PDFFilePath As String
  Dim PDFFileName As String

 Set dlgSaveAs = Application.FileDialog( _
 FileDialogType:=msoFileDialogSaveAs)
 dlgSaveAs.Show

strPath = _
        Application.FileDialog(msoFileDialogSaveAs).SelectedItems(1)

  strPath = Left$(strPath, InStrRev(strPath, ".") - 1)
 PDFFilePath = strPath & ".pdf"

ActiveDocument.ExportAsFixedFormat OutputFileName:=PDFFilePath_
        , ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
        wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
        Item:=wdExportDocumentContent, IncludeDocProps:=False, KeepIRM:=False, _
        CreateBookmarks:=wdExportCreateHeadingBookmarks, DocStructureTags:=True, _
        BitmapMissingFonts:=False, UseISO19005_1:=False

'strPath = ActiveDocument.FullName ', ActiveDocument.
     
'Start Outlook if it isn't running
 Set olApp = GetObject(, "Outlook.Application")
 If Err <> 0 Then
 Set olApp = CreateObject("Outlook.Application")
 End If

'Create a new message
 Set olItem = olApp.CreateItem(olMailItem)
 olItem.Display
 olItem.Attachments.Add PDFFilePath
 olItem.Subject = "my subject"
End Sub
 
Last edited:
BTW, can't you edit the subject of the open email without first saving and closing? (I can, but using outlook 2016.)
 
The macro i posted worked in 21016 but not 2010 - i fixed it so it works in 2010.
 
Last edited:
Well... Wow. Thank you Diane Poremsky! I actually don't need to save the PDF I'm sending these days, but I'm going to give that a whirl.

Yes something about Adobe PDF generated from word into an outlook email doesn't want to play nicely in 2010. outlook either wants you to send the email or save the email as a draft before it will let you take any other action in its email functions. It is a bit of a plague. It sounds like they have fixed that in later versions. Thank you, and I will give your script a go. That is really great. Thank you!
 
Hmmm. I gave it a shot Diane, In Word correct? I get an error message when I try and run it: Compile Error: Syntax error.
This part shows up in Red:
ActiveDocument.ExportAsFixedFormat OutputFileName:=PDFFilePath_
, ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=False, KeepIRM:=False, _
CreateBookmarks:=wdExportCreateHeadingBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=False, UseISO19005_1:=False

So I wonder if something has gone awry from copying it overh
 
Yes, in word. i will test it again in 2010 and see if i can replicate it. one thing you can try is either add a space before the _ here: PDFFilePath_ or use backspace to move the comma so its PDFFilePath, exportformat....
 
Thank you so much Diane, I will try that.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
O How to find and replace a word in Outlook-Agenda-Subject and Message? Using Outlook 0
M Outlook 2013 Replace Subject with Conversation (a "hidden" value). Outlook VBA and Custom Forms 0
V Replace only part of subject in OUTLOOK 2003 Outlook VBA and Custom Forms 1
O Replace hard returns with soft returns on selected text and button to QAT Using Outlook 5
Beeto Replace a string in body Outlook VBA and Custom Forms 2
S HTML Code Embedded in String Within Open Outlook Email Preventing Replace(Application.ActiveInspector.CurrentItem.HTMLBody From Working Outlook VBA and Custom Forms 4
F Copy and replace not update contact in another pst Using Outlook 0
B Automatically Forward Emails and Remove/Replace All or Part of Body Outlook VBA and Custom Forms 8
C How to replace or delete first instance of sentence in mail body? Outlook VBA and Custom Forms 1
Diane Poremsky How to perform a global search and replace Using Outlook 0
B Delete/replace old files and save new attachments Using Outlook 1
Diane Poremsky Replace Display Names with Email Addresses Using Outlook 0
mrje1 Is there a Find and Replace feature in Outlook 2016? Using Outlook 4
J Pull an email address from body and replace reply-to address Outlook VBA and Custom Forms 4
divan Outlook 2007 - Replace email body with custom text Using Outlook 9
E VBScript to replace module? Using Outlook 3
A How to replace column title in address book Using Outlook 1
A Replace olFolderContacts for Sharepoint lists in Outlook Outlook VBA and Custom Forms 5
P replace default outlook form with custom form Outlook VBA and Custom Forms 1
A How to replace getcontactsfolder (ol2007) in Outlook 2003 Outlook VBA and Custom Forms 2
H using VBA to edit subject line Outlook VBA and Custom Forms 0
F Auto changing email subject line in bulk Using Outlook 2
M Outlook Macro to save as Email with a file name format : Date_Timestamp_Sender initial_Email subject Outlook VBA and Custom Forms 0
J Outlook 365 Forward Email Subject to my inbox when new email arrive in shared inbox Using Outlook 0
sjmo2 Change subject for new e-mails only. Outlook VBA and Custom Forms 2
C Outlook 365 Copy/Save Emails in Folder Outside Outlook to Show Date Sender Recipient Subject in Header Using Outlook 0
D Prompt to prefix subject line whenever sending an email Outlook VBA and Custom Forms 3
ill13 Prepend the user's computer name to the subject. Outlook VBA and Custom Forms 1
D Auto Remove [EXTERNAL] from subject - Issue with Macro Using Outlook 21
2 How to get rid of the "Emailing:" prefix in the subject line Using Outlook 1
S Outlook Macro for [Date][Subject] Using Outlook 1
D ISOmacro to extract active mail senders name and email, CC, Subject line, and filename of attachments and import them into premade excel spread sheet Outlook VBA and Custom Forms 2
C Outlook 365 Subject Prefixes? Outlook VBA and Custom Forms 1
A Macro to file emails into subfolder based on subject line Outlook VBA and Custom Forms 1
N Save selected messages VBA does not save replies and/or messages that contain : in subject Outlook VBA and Custom Forms 1
V vBA for searching a cell's contents in Outlook and retrieving the subject line Outlook VBA and Custom Forms 1
C Macro to extract sender name & subject line of incoming emails to single txt file Outlook VBA and Custom Forms 3
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
R Disable conversation thread from replying of recipients in the same subject. Please help Using Outlook 0
M Outlook 2013 Script Assistance - Save Opened Link with Subject Added Outlook VBA and Custom Forms 1
C How to rename subject line and forward the email Outlook VBA and Custom Forms 2
B Add Prefix text to Subject Line Using Outlook 1
P [SOLVED] Auto remove [EXTERNAL] from subject Using Outlook 16
M Convert Subject Line to Internet Header version of Subject Outlook VBA and Custom Forms 10
M Adding Subject to this Link-Saving VBA Outlook VBA and Custom Forms 5
P Auto Insert Current Date or Time into Email Subject Outlook VBA and Custom Forms 2
M VBA to auto forward message with new subject and body text Outlook VBA and Custom Forms 8
L Moving emails with similar subject and find the timings between the emails using outlook VBA macro Outlook VBA and Custom Forms 1
A Edit subject - and change conversationTopic - using VBA and redemption Outlook VBA and Custom Forms 2
B Remove Subject Residual Outlook VBA and Custom Forms 3

Similar threads

Back
Top