Forum Discussion
Using Mail Merge with MACROS
Hi! A Word macro is not applied separately to each merged pageāthe merged result is one document containing sections. Run the formatting macro after MailMerge.Execute, loop through the resulting document's sections or paragraphs rather than a fixed number of lines, and export the completed result to PDF only after that loop finishes.
- ChrisBlanchardJul 13, 2026Copper Contributor
Hello Jamony
I do not know how to address the next section to apply the MACRO. Although the resulting pdf occupied two pages addressing the second page using (an absolute setting for test purposes):
Selection.GoTo wdGoToPage, wdGoToAbsolute, 2
merely resulted in the MACRO applied to the 1st page again, which is what you suggested could happen
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord - this worked interactively but would not work with the actual merge to create the document, as I presume merge would no longer be active then, and even then some changes from the previus page were carried over
I had two tables on a single page so I wondered if the merge would generate extra tables on the next page for the same document
Thus, I used:
ActiveDocument.Tables(1).Cell(index, 1).Select
To select the 1st cell in the table on the 1st page
I wondered if new Tables were created for subsequent pages in the same active document
when I ran
ActiveDocument.Tables(3).Cell(index, 1).Select
the table was not found
I tried to see if the SECTIONS property of ACTIVEDOCUMENT could be used
ActiveDocument.Sections.Count = 2
An attempt at using this to navigate resulted in an error applying an assignment to a read only property
I still seem to be trapped applieing my macro to the 1st page of the document
regards