qertnewsletter.blogg.se

Office 365 mergepdf
Office 365 mergepdf









The fields DocFolderPath and PdfFolderPath should contain paths to folders which exist on your system. These should be exactly as written here, with no spaces and each word capitalised.

office 365 mergepdf

a sheet in Excel with headers in the first row and data underneath.įor the macro to work, you will need to add in four extra columns named: DocFolderPath, DocFileName, PdfFolderPath, and PdfFileName. Start by preparing your data exactly as you would for a normal mail merge – i.e.

office 365 mergepdf

Copy the Macro from this article and paste it into the middle of the VBA editor. The middle of the window will be a white canvas – this is the editing space for the new module. A new file called “Module1” will appear in the Modules folder under “Normal” (the file may have a different number if Module1 already exists). In this window right-click on “Normal” and in the contextual menu select “Insert” and then “Module”. If you do not see a window called “Project” then click on the View menu and select “Project Explorer”. This contains the Visual Basic and Macro buttons on the left-hand side.Ĭlick the Visual Basic button in the Developer tab to open the Visual Basic editor where we will add our macro. Once done press Ok, and the Developer tab will appear in the Ribbon. In the dialogue box which appears make sure the checkbox next to Developer in the right-hand column is checked. To make it appear is you just right-click anywhere in the ribbon and select “Customise the Ribbon”. If you don’t have this appearing, that’s perfectly normal for Word, they hide it by default. To add a macro to Word you will need to be able to see the Developer tab. Next recordNum ' Add one to "recordNum" and return to the beginning of the loop (line under "For recordNum = 1.

#OFFICE 365 MERGEPDF PDF#

and end points to the same number (which is the same as the active record)įileName:=("DocFolderPath").Value & "/" & _įileName:=("PdfFolderPath").Value & "/" & _įileFormat:=wdFormatPDF ' Export "singleDoc" as a PDF with the details provided in the PdfFolderPath and PdfFileName fields in the MailMerge data = 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 ("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 & _ False ' run the MailMerge based on the above settings (i.e. = ' Limit the selection to just one document by setting the start.

office 365 mergepdf

= 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

office 365 mergepdf

Sub MailMergeToPdfBasic() ' Mark the start of the Subroutine (i.e.









Office 365 mergepdf