triadaquality.blogg.se

Doc merge to pdf
Doc merge to pdf













doc merge to pdf

= recordNum ' Limit the selection to just one document by setting the start. = recordNum ' Change the active record in the MailMerge to the "recordNum" = wdLastRecordįor recordNum = 1 To ' Set "recordNum" to 1 and start loop | second part defines end point for loop Macro) and name it "MailMergeToPdf"ĭim masterDoc As Document, recordNum As Long, singleDoc As Document ' Create variables ("Post-it Notes") for later use Sub MailMergeToPdf() ' Mark the start of the Subroutine (i.e. = wdNextRecord ' otherwise go to the next active record LastRecordNum = 0 ' if so we set lastRecordNum to zero to indicate that the loop should end If >= lastRecordNum Then ' test if we have just created a document for the last record SingleDoc.Close False ' Close "singleDoc", the variable "singleDoc" can now be used for the next record when created

Doc merge to pdf pdf#

("PdfFileName").Value & ".pdf", _ĮxportFormat:=wdExportFormatPDF ' Export "singleDoc" as a PDF with the details provided in the PdfFolderPath and PdfFileName fields in the MailMerge data OutputFileName:=("PdfFolderPath").Value & Application.PathSeparator & _ ("DocFileName").Value & ".docx", _įileFormat:=wdFormatXMLDocument ' Save "singleDoc" as a word docx with the details provided in the DocFolderPath and DocFileName fields in the MailMerge data Set singleDoc = ActiveDocument ' Identify the ActiveDocument (foremost doc after running the MailMerge) as "singleDoc"įileName:=("DocFolderPath").Value & Application.PathSeparator & _

doc merge to pdf

False ' run the MailMerge based on the above settings (i.e. = ' Limit the selection to just one document by setting the start. = wdSendToNewDocument ' Identify that we are creating a word docx (and no e.g. = wdFirstRecord ' jump to the first active record (active = ticked in edit recipients)ĭo While lastRecordNum > 0 ' create a loop, lastRecordNum is used to end the loop by setting to zero (see below) LastRecordNum = ' retrieve the record number of the last active record so we know when to stop = wdLastRecord ' jump to the last active record (active = ticked in edit recipients) Set masterDoc = ActiveDocument ' Identify the ActiveDocument (foremost doc when Macro run) as "masterDoc" ' Please share freely while retaining attributionĭim masterDoc As Document, singleDoc As Document, lastRecordNum As Long ' Create variables ("Post-it Notes") for later use Sub MailMergeToPdfBasic() ' Mark the start of the Subroutine (i.e.















Doc merge to pdf