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!
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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:

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
BTW, can't you edit the subject of the open email without first saving and closing? (I can, but using outlook 2016.)
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
The macro i posted worked in 21016 but not 2010 - i fixed it so it works in 2010.
 
Last edited:

Carla100

New Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server
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!
 

Carla100

New Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server
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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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....
 

Carla100

New Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server
Thank you so much Diane, I will try that.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
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
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 New Slipstick.com Articles 0
B Delete/replace old files and save new attachments Using Outlook 1
Diane Poremsky Replace Display Names with Email Addresses New Slipstick.com Articles 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
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 14
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
F VBA to ensure a code is entered in Subject title Outlook VBA and Custom Forms 1
A Check for words in subject header before sending email Outlook VBA and Custom Forms 4
J VBA Outlook : Subject line : Cut and Paste name to heading , number to very end of the body of Email Outlook VBA and Custom Forms 1
Z Outlook Custom Form: Adding Dropdown(Project Code) at the end of subject Outlook VBA and Custom Forms 0
D Remove text in subject using VBA Outlook VBA and Custom Forms 4
M Making Subject field writable (disable Read Only) Outlook VBA and Custom Forms 2
M Adding Macro to populate "to" "subject" "body" not deleting email string below. Outlook VBA and Custom Forms 5
G Download pdf attachments only if email subject has one of words Outlook VBA and Custom Forms 8
C Change Subject Line in Selected Emails Outlook VBA and Custom Forms 1
M Macro to add date/time stamp to subject Outlook VBA and Custom Forms 4
D Edit Subject (Multiple Accounts) Outlook VBA and Custom Forms 5
E Outlook 2010 Subject sort uses Thread-Topic for grouping Using Outlook 2
C Outlook - cannot save subject line changes Using Outlook 2
J Open an outlook email by Subject on MS Access linked table with VBA Outlook VBA and Custom Forms 10
E Search for folder by key in subject then move new message to related folder Outlook VBA and Custom Forms 1
R Chancing / remove “ something ” in the subject, online archive Outlook VBA and Custom Forms 8
I print calendar without subject and details Using Outlook 1
O On click,I want to change subject line of selected mail and then reply to particular email and move Using Outlook 3
K Update subject based on text in body Outlook VBA and Custom Forms 3
N Select Appointment subject line from combobox or list Outlook VBA and Custom Forms 1

Similar threads

Top