VBA & Macro Problems

How to Auto-Populate a Word Template from Excel by Client Number

Algirdas JasaitisAlgirdas Jasaitis Oct 22, 2026 874 views

Question details

The user needs to automatically retrieve and fill client details, such as name and email, into a Word document by inputting a client number stored in an Excel workbook.

How to Auto-Populate a Word Template from Excel by Client Number
Product
Word, Excel
Device & OS
not provided
Scenario
Creating client-specific documents or templates by looking up records dynamically in a spreadsheet database.
Observed behavior
The user wants to input a specific client number in Word and have the corresponding client information automatically populated from an Excel data source, replacing manual data entry.
Before you start

Ensure your Excel dataset is organized with clear column headers (e.g., Client Number, Name, Email) in the first row with no blank rows above it. If you plan to use VBA UserForms, make sure macros are enabled in your Word Trust Center settings.

Solution 1Recommended

Use Word Mail Merge for Bulk or Simple Auto-Population

Mail Merge is a built-in feature that connects a Word document to an Excel dataset, allowing you to easily insert standard merge fields for names, emails, and client numbers.

While Mail Merge is traditionally used for bulk document generation, it can be filtered to produce a single document for a specific client number. Note that once you complete the merge, the final document becomes static and is no longer connected to the Excel data source.

1
Prepare the Excel data

Open your Excel workbook, ensure all columns have descriptive headers like 'Client Number' and 'Name', and save the file.

2
Connect Excel to Word

Open your Word template, go to the 'Mailings' tab, click 'Select Recipients', choose 'Use an Existing List', and browse for your saved Excel workbook.

3
Insert Merge Fields

Place your cursor where you want the data to appear in the template, click 'Insert Merge Field' on the Mailings tab, and select the corresponding column headers.

4
Filter and Merge

Click 'Edit Recipient List' to filter by a specific client number. Once selected, click 'Preview Results' to verify the data, then click 'Finish & Merge' to generate the completed document.

Use Word Mail Merge for Bulk or Simple Auto-Population
Static Output: Completing the merge creates a plain document. If the source Excel data updates later, the already merged document will not reflect those changes.
Automate Documents with WPS Office

Auto-Populate Templates Using WPS Office

WPS Writer fully supports Mail Merge and VBA macros, allowing you to effortlessly connect spreadsheets to document templates for quick, automated client data entry.

  1. 1. Open your template: Launch WPS Writer and open the document you wish to use as your base template.
  2. 2. Connect the data source: Navigate to the 'Mailings' tab and click 'Open Data Source' to load your WPS Spreadsheet containing the client data.
  3. 3. Insert fields: Use the 'Insert Merge Field' button to add placeholders for your client information.
  4. 4. Merge to document: Filter for the client number you need, then click 'Merge to New Document' to generate the populated file instantly.
Fully compatible with Microsoft Word and Excel file formats (.docx, .xlsx, .dotm)Intuitive Mailings tab for simple step-by-step data mergingRobust support for VBA macros for advanced UserForm automationLightweight, fast, and free to use
microsoft office alternative - wps office

Frequently Asked Questions

Why does my completed Mail Merge document lose connection to the Excel file?

Once you click 'Finish & Merge', the software generates a new, static document containing the final text to prevent unintended overwrites. The original template file remains connected to the Excel file, but the generated output does not.

Can I pull Excel data into Word without using Mail Merge or VBA?

Yes, you can copy specific cells in Excel, switch to Word, and choose 'Paste Special' > 'Paste Link'. This inserts the data as a Linked Object, meaning any changes made in Excel will automatically update in Word.

Why aren't my VBA macros running in my Word template?

Macros are often blocked by default security settings. Go to File > Options > Trust Center > Trust Center Settings > Macro Settings, and ensure macros are enabled. Additionally, make sure you have saved the document as a Macro-Enabled Template (.dotm) rather than a standard .docx file.