Hello all,
I am writing a Macro in word (have done plenty in excel, not so much in MS Word). The Macro will take a mail merge document, open the first merge record as a new document, update all fields (to get the image to update) and then export as a PDF.
I have 2 updates that need to be made to this code in order for it to work perfectly.
1st I need to loop this process to move on to the next merge record in the main mail merge document, open as a new document and export as a PDF and so on until all Merge records have generated an individual PDF file.
2nd is I need the file name of the PDF to change based on a merge field (employee ID for example).
The end result would be multiple PDF documents saved to a folder with file names based on the employee's ID.
What I have so far is:
[VBA]Sub Macro1()
'
' Macro1 Macro
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord
.LastRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord
End With
.Execute Pause:=False
End With
ActiveWindow.ActivePane.VerticalPercentScrolled = 64
Selection.WholeStory
Selection.Fields.Update
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
"Q:\GENERIC FILE PATH" & ".pdf", 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
ActiveWindow.Close
End Sub[/VBA]
Any help with the two items above would be GREATLY appreciated!!!
Thanks for taking the time to look