Print All Word Mail Merge Records from the Command Line
Question details
Print the complete Word mail merge from a command-line batch file using a specified printer.

- Product
- Microsoft Word
- Device & OS
- Windows
- Scenario
- A batch file needs to print all records in a Word mail merge to a printer other than the default.
- Observed behavior
- The current command-line print job prints only the first mail merge record.
Open the merge document in Word and confirm that its data source is connected and the intended records are included. Install the target printer in Windows and ensure that Word macros are permitted by your organization's security settings.
Run a Word VBA macro that merges all records to a chosen printer
Use this approach when a batch file must execute the merge rather than print only the main document.
The macro opens the merge document, selects a printer, and sends the selected merge records directly to it without showing the print dialog. Existing mail merge filters and excluded records still apply.
Store the macro in Word's Normal template so it is available when Word starts. Use only trusted macros and documents.
In Word, open File > Print and select the target printer. Press Alt+F11, open the Immediate window with Ctrl+G, and enter ?Application.ActivePrinter. Copy the displayed value exactly.
In the VBA editor, select Normal in the Project pane, choose Insert > Module, and paste the following code. Replace the document path and printer value with your own: Sub PrintAllMergedRecords() Dim mergeDoc As Document Dim previousPrinter As String On Error GoTo Failed previousPrinter = Application.ActivePrinter Set mergeDoc = Documents.Open(FileName:="C:\Merge\Letters.docx", ReadOnly:=True) Application.ActivePrinter = "Your printer name on its port" With mergeDoc.MailMerge .Destination = wdSendToPrinter .DataSource.FirstRecord = wdDefaultFirstRecord .DataSource.LastRecord = wdDefaultLastRecord .Execute Pause:=False End With CleanUp: On Error Resume Next If Not mergeDoc Is Nothing Then mergeDoc.Close SaveChanges:=wdDoNotSaveChanges If previousPrinter <> "" Then Application.ActivePrinter = previousPrinter Exit Sub Failed: Debug.Print "Mail merge error " & Err.Number & ": " & Err.Description Resume CleanUp End Sub
Save the Normal template when prompted, then use Developer > Macros to run PrintAllMergedRecords. Check the target printer's queue and confirm that all intended records appear.
Add a command such as "C:\Path\To\WINWORD.EXE" /mPrintAllMergedRecords to your .bat file, replacing the executable path with the location of WINWORD.EXE on your computer. The macro opens the document using the path configured in its code.

Work with Word documents in WPS Writer
WPS Office is a free, lightweight alternative for opening and editing Word documents in a familiar interface. Its Microsoft Office format support makes it easier to move existing files into WPS, though it does not fix Word's command-line macro behavior.

Frequently Asked Questions
Why does the batch file print only the first merge record?
Printing the main Word document is not the same as executing its mail merge. Set MailMerge.Destination to wdSendToPrinter and call MailMerge.Execute to print the selected records.
How do I find the printer name for the macro?
Select the printer in Word under File > Print. Then press Alt+F11, open the Immediate window with Ctrl+G, and run ?Application.ActivePrinter to see the value Word uses.
Will the macro print records excluded by a mail merge filter?
No. The macro requests the full record range, but existing filters and excluded recipients still apply. Review the recipient list in Word before running it.
Can the merge run without any prompts?
The macro suppresses the print dialog, but Word may still show data-source security prompts or printer errors. Test the document, data connection, and printer under the same account that will run the batch file.




