How to Fix Word 365 VBA Mail Merge Stopping After 254 Records
Question details
A Word 365 VBA script used for a mail merge stops generating separate PDF files exactly after processing 254 records, resulting in an incomplete merge.

- Product
- Microsoft Word 365
- Device & OS
- not provided
- Scenario
- Automating a mail merge to separate PDF files using a VBA macro, where the script fails to iterate through the entire dataset.
- Observed behavior
- The VBA macro stops processing at 254 records. This is typically caused by data source limits, an incorrect VBA loop condition, or a null ID value rather than an inherent Word limitation.
Ensure you have a complete backup of your original Word document and Excel data source before modifying any VBA macro code.
Verify the Data Source Record Count Using VBA
Use a message box in your VBA code to verify the exact number of records Word is fetching from your data source to confirm if the issue is a data limitation.
Often, Word is only receiving 254 records from the OLE DB connection. Verifying the exact count helps narrow down whether the issue is with the Word loop or the Excel data connection.
Press Alt + F11 in Word to open the Microsoft Visual Basic for Applications window, then locate your mail merge macro module.
Before the loop that processes the records, insert the line: MsgBox .DataSource.RecordCount
Run the script. A message box will appear displaying the total records Word detects. If it says 254, your data source connection is limiting the fetch.

Check the Data Source for Null ID Values
Inspect the 255th row of your data source to ensure an empty or invalid ID field isn't prematurely triggering the exit condition of your VBA loop.
Use a Dedicated Mail Merge Add-in
Bypass VBA limitations and OLE DB row caps by utilizing a third-party add-in designed to merge and split records into individual PDF files.
Try WPS Office for Seamless Document Management and Mail Merge
If troubleshooting complex VBA macros and data source connection limits in Microsoft Word 365 is slowing down your workflow, consider switching to WPS Office. It provides a lightweight, highly compatible alternative with powerful built-in document generation tools that handle large datasets effortlessly.
- 1. Download WPS Office: Visit the official WPS website, download the free suite, and install it on your device.
- 2. Open Your Files: Launch WPS Writer and open your existing .docx file and .xlsx data source directly, with full formatting preserved.
- 3. Utilize Mail Merge: Navigate to the References tab to access the intuitive Mail Merge toolkit, making bulk document creation straightforward.

Frequently Asked Questions
Is there a hard limit of 254 records for mail merge in Word 365?
No, Microsoft Word 365 does not have a hard limit of 254 records for mail merges. The issue is usually caused by limitations in the OLE DB data connection method fetching from Excel, or an empty cell at row 255 causing a VBA loop to terminate.
Why do I get a compile error when checking the record count in VBA?
A compile error occurs if you use incorrect syntax to check the record count. Adding a period between 'Record' and 'Count' (like .DataSource.Record.Count) is invalid. The correct property to use is .DataSource.RecordCount without the extra dot.
How can I merge records to separate PDF files without using VBA?
If you want to avoid VBA scripting entirely, you can use specialized mail merge add-ins available for Word, or switch to alternative office software that features more robust native options for splitting merged documents into individual PDFs.




