VBA & Macro Problems

How to Use Excel VBA to Update Word Mail Merge Labels

Olivia MillerOlivia Miller Nov 3, 2026 870 views

Question details

The user needs to dynamically update Word mail merge labels using Excel VBA, but the labels fail to reflect new data records when the script runs.

How to Use Excel VBA to Update Word Mail Merge Labels
Product
Microsoft Word and Excel
Device & OS
not provided
Scenario
Automating the creation and updating of a mail merge label document directly from an Excel data source using VBA scripts.
Observed behavior
Excel VBA successfully opens the Word label document and connects to the data source, but the mail merge labels do not update with the new records.
Before you start

Ensure that both your Excel data source workbook and the target Word label document are saved locally in a trusted directory, and that macro execution is enabled in your Excel Trust Center settings.

Solution 1Recommended

Use the Word MailMerge Object Model in Excel VBA

Utilize Word's native MailMerge object model instead of relying on basic macro recordings or SendKeys to ensure the data source is properly refreshed and merged.

When automating mail merges between Excel and Word, basic recorded macros often fail to refresh the data connection. By scripting directly against the Word MailMerge object model, you can explicitly force Word to fetch the latest records from your Excel file using the OpenDataSource method.

1
Open the VBA Editor

Press Alt + F11 in Excel to open the Visual Basic for Applications (VBA) editor.

2
Add the Word Object Library Reference

In the VBA editor, go to the top menu and click Tools > References. Scroll down the list, check 'Microsoft Word Object Library', and click OK. This allows your Excel macro to command Word.

3
Write the MailMerge Code

Insert a new module (Insert > Module) and declare your Word Application and Document objects. Use the 'MailMerge.OpenDataSource' method in your script to point directly to your Excel file path and specify the SQL statement for the desired worksheet.

4
Execute and Save the Merge

Add the 'MailMerge.Execute' command to generate the final merged document. Follow this with a command to save the resulting document to your preferred folder path.

Use the Word MailMerge Object Model in Excel VBA
Avoid SendKeys: Never use the SendKeys method for mail merge automation. It is highly unstable and will break if the application loses focus. Always use the dedicated MailMerge object methods.
Free Microsoft Office alternative

Create Mail Merge Labels Easily with WPS Office

If complex VBA scripting isn't for you, WPS Office offers a highly intuitive, built-in Mail Merge feature that seamlessly connects spreadsheets to text documents without requiring a single line of code. It's a lightweight and highly compatible alternative to Microsoft Office.

Fully compatible with Microsoft Excel (.xlsx) and Word (.docx) formats.Built-in, user-friendly Mail Merge wizard that requires no VBA knowledge.Powerful macro support for users who want to automate repetitive tasks.Free, lightweight, and fast-loading office suite.Seamless transition from MS Office with a familiar tabbed user interface.
microsoft office alternative - wps office

Frequently Asked Questions

Why aren't my Word mail merge labels updating with new Excel data?

This usually happens if the Word document doesn't explicitly refresh its data connection upon opening. Using the OpenDataSource method in VBA forces Word to re-establish the link and fetch the latest records from your Excel file.

Can I run a mail merge entirely from Excel without opening Word?

Word must be opened in the background because the MailMerge engine belongs to Word, not Excel. You can hide the Word application window during the process by setting the Word.Application.Visible property to False in your VBA script.

How do I avoid the SQL security prompt when opening a mail merge document via VBA?

The SQL security warning can interrupt VBA execution. You can suppress it by temporarily disabling application alerts using 'Application.DisplayAlerts = False' in your script before opening the document, or by modifying the SQLSecurityCheck registry key for Word.

What is the OpenDataSource method in VBA?

OpenDataSource is a method of the Word MailMerge object that allows you to programmatically attach a data source, such as an Excel workbook, to a Word document and specify the exact sheet or data table to pull records from.