Others

How to Fix Word 365 VBA Mail Merge Stopping After 254 Records

Chanuka GeekiyanageChanuka Geekiyanage Nov 2, 2026 869 views

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.

How to Fix Word 365 VBA Mail Merge Stopping After 254 Records
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.
Before you start

Ensure you have a complete backup of your original Word document and Excel data source before modifying any VBA macro code.

Solution 1Recommended

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.

1
Open the VBA Editor

Press Alt + F11 in Word to open the Microsoft Visual Basic for Applications window, then locate your mail merge macro module.

2
Insert Record Count Check

Before the loop that processes the records, insert the line: MsgBox .DataSource.RecordCount

3
Run the Macro

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.

Verify the Data Source Record Count Using VBA
Syntax Warning: Ensure you type .DataSource.RecordCount exactly. Adding a period between Record and Count (e.g., .DataSource.Record.Count) will result in a compile error.
Free Microsoft Office alternative

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. 1. Download WPS Office: Visit the official WPS website, download the free suite, and install it on your device.
  2. 2. Open Your Files: Launch WPS Writer and open your existing .docx file and .xlsx data source directly, with full formatting preserved.
  3. 3. Utilize Mail Merge: Navigate to the References tab to access the intuitive Mail Merge toolkit, making bulk document creation straightforward.
Fully compatible with Microsoft Word (.docx) and Excel (.xlsx) formats.Built-in PDF conversion tools to simplify exporting documents without coding.Lightweight architecture that processes large files and datasets smoothly.Familiar user interface ensuring a zero-learning-curve transition.
microsoft office alternative - wps office

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.