
#MAIL MERGE FOR TEXT MESSAGES MAC PDF#
I changed the code a tiny bit so that when it saves as a PDF it saves the whole document, that was a mistake on my part. ' ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc" LeftMargin = CentimetersToPoints(1.27) '1.27 BottomMargin = CentimetersToPoints(1.27) TopMargin = CentimetersToPoints(1.27) '1.27cm Selection.PasteAndFormat (wdFormatOriginalFormatting) MsgBox "The documents will be saved in the default document file location."ĪctiveDocument.Bookmarks("Section").Range.Copy Title = "Select the folder into which the documents will be saved." Set fd = Application.FileDialog(msoFileDialogFolderPicker) ' Select a folder, change the default file save location below so it's not just C: You'll have to replace the margins section with the margins you want or delete the section It the original but you can choose where to save it, it changes the margins on the page it's pasted on and then it removes the section break after it has pasted.īy removing the section break it means that there should be no blank page at the end. For additional information on using the macro, refer to the Knowledge Base article at the link provided above. If your original document includes section breaks, then the macro will not provide satisfactory results. It is important to realize, however, that this macro will only work if the only place that section breaks occur is between merged documents.

'Move the selection to the next section in the documentĪctiveDocument.Close savechanges:=wdDoNotSaveChanges Selection.Delete Unit:=wdCharacter, Count:=1ĪctiveDocument.SaveAs FileName:="test_" & DocNum & ".doc" Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend 'Removes the break that is copied at the end of the section, if any. 'Create a new document to paste text from clipboard. 'Select and copy the section text to the clipboardĪctiveDocument.Bookmarks("\Section").Range.Copy 'Subtracting one from the section count stop error message.įor i = 1 To (() - 1) 'A mailmerge document ends with a section break next page. 'Used to set criteria for moving through the document by section.Ī = wdBrowseSection It allows you to separate a merged document into individual files, based on the section breaks: The macro presented in the article, even though it was written for an older version of Word, will work just fine in later versions. If you look in Microsoft's Knowledge Base, you will find that there is an old article that deals with this very issue:

The only answer to accomplishing this task is to create a macro that will, based on the merged document (the 300-page one mentioned above) take each section and save it to its own document file. Unfortunately, that is not one of the options available when using Word's mail-merge feature. For instance, given the above example you might want 150 individual document files, each two pages long. Thus, if you are merging the two-page letter with 150 different addresses, then you would end up with a 300-page document with 150 section breaks (one every two pages).įor some people, it would be more helpful if you could merge to individual files. For instance, if your merge document is a two-page letter, each letter in the resulting document is separated by a section break. If you choose the latter option, the resulting document contains all the information that normally would have gone to the printer.

When you use the mail-merge feature in Word, you have the option of either printing your results directly or creating a new document.
