Document Editing Problems

How to Add Dynamic Images to a Microsoft Word Mail Merge

Rana GarciaRana Garcia Nov 3, 2026 870 views

Question details

The user needs to insert varying JPEG images into a Microsoft Word mail merge based on file paths stored in a data source column.

How to Add Dynamic Images to a Microsoft Word Mail Merge
Product
Microsoft Word
Device & OS
not provided
Scenario
Performing a mail merge that requires different images to be generated for each individual merged document.
Observed behavior
Requires the correct formatting and insertion of nested field codes so that the corresponding image loads properly for each record during the document merge.
Before you start

Ensure that your data source (such as an Excel spreadsheet) contains a dedicated column with the exact, full file paths to your images, and verify that the image files actually exist in those directory locations.

Solution 1Recommended

Use Nested INCLUDEPICTURE and MERGEFIELD Field Codes

Insert dynamic images by combining the INCLUDEPICTURE and MERGEFIELD codes in your Word document to pull file paths directly from your data source.

To make images change dynamically per record, you must nest a MERGEFIELD code inside an INCLUDEPICTURE field code. Standard insertion of a merge field will only output the text of the file path, not the image itself.

1
Insert the first field code

Click where you want the image to appear. Press Ctrl + F9 on your keyboard to insert a pair of field code braces { }.

2
Add the INCLUDEPICTURE command

Inside the braces, type INCLUDEPICTURE followed by a space, quotation marks, and the \d switch. It should look like this: { INCLUDEPICTURE "" \d }.

3
Insert the nested MERGEFIELD code

Place your text cursor directly between the empty quotation marks and press Ctrl + F9 again to insert a second set of braces.

4
Specify the data source column

In the new inner braces, type MERGEFIELD followed by a space and your data source column name (e.g., PictureLocation). The final code must look exactly like: { INCLUDEPICTURE "{ MERGEFIELD PictureLocation }" \d }.

5
Complete the merge and update fields

Finish your mail merge to a new document. Select all text in the new document by pressing Ctrl + A, then press F9 to refresh the fields and force the images to display.

Use Nested INCLUDEPICTURE and MERGEFIELD Field Codes
Image Sizing and File Paths: The '\d' switch ensures the image data isn't saved in the document, keeping the file size small. Ensure that your data source file paths use double backslashes (e.g., C:\\Images\\photo.jpg) for the best compatibility.
Efficient Mail Merge with WPS Office

Create Dynamic Mail Merges Effortlessly in WPS Writer

WPS Writer offers a comprehensive Mail Merge feature that seamlessly handles data sources and field codes. You can easily merge text and dynamic images while enjoying a highly intuitive interface.

  1. 1. Prepare your document: Open your main document in WPS Writer and navigate to the 'Mailings' or 'References' tab on the top ribbon.
  2. 2. Link your data source: Click 'Open Data Source' and select your spreadsheet containing the image file paths.
  3. 3. Insert the field codes: Use Ctrl + F9 to manually insert the nested INCLUDEPICTURE and MERGEFIELD codes, just as you would in standard Word processing.
  4. 4. Merge and update: Click 'Merge to New Document' to generate your files, then press Ctrl + A and F9 to refresh and reveal the dynamic images.
Fully compatible with Microsoft Word (.docx) formats and field code commands like INCLUDEPICTURE.Seamlessly connect to Excel spreadsheets (.xlsx) for your mail merge data sources.Lightweight, fast, and completely free to use for your daily document processing needs.Familiar ribbon interface ensures a zero-learning-curve migration from Microsoft Office.
microsoft office alternative - wps office

Frequently Asked Questions

Why are my images not showing up after completing the mail merge?

Word does not always automatically update nested field codes upon merging. You must force the fields to update by pressing Ctrl + A to select the entire merged document, and then pressing F9 on your keyboard to refresh the codes and load the images.

Do I need to format the file paths in my Excel spreadsheet a specific way?

Yes, in many cases, Windows file paths in data sources require double backslashes (e.g., C:\\Images\\photo.jpg) instead of single backslashes so the merge field correctly interprets the directory path without escaping characters.

Can I use relative file paths for my mail merge images?

Using full absolute paths (e.g., C:\Users\Name\Documents\Images) is highly recommended. Relative paths often break depending on where the merged document is saved or executed from, resulting in broken image links.

How can I make all the dynamic images exactly the same size?

The INCLUDEPICTURE field brings in the image at its native resolution or size. To ensure uniformity, it is best to resize all your source images to the exact same dimensions in an image editor before running the mail merge, or place the field code inside a fixed-size table cell to constrain its dimensions.