Log in

View Full Version : VBA Code: Send email header to pdf using wrdApp.ActiveDocument.ExportAsFixedFormat



inddon
04-08-2016, 02:48 AM
Hello There,

I am using a VBA code to export contents of email to a pdf file as below:


'Save as pdf
wrdApp.ActiveDocument.ExportAsFixedFormat OutputFileName:= _
strCurrentFile, ExportFormat:= _
wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False

With the above code, it send the entire email. I want only the below email header in the pdf file:
From:
To:
Date:
Subject:


Could you please guide in how to modify the above code. Appreciate your help

Thanks
Don

inddon
04-08-2016, 03:30 AM
Hello There,

Came across the solution, where I just wanted to have the email header. Sharing the code is as below:



'Remove the lines. Start from the 5th line to the end . This means keep only the first 4 lines
wrdDoc.Range(wrdDoc.Paragraphs(5).Range.Start, wrdDoc.Range.End).Cut

'Save as pdf
wrdApp.ActiveDocument.ExportAsFixedFormat OutputFileName:= _
strCurrentFile, ExportFormat:= _
wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False



Regards,
Don