Share via

Mail Merge With Variable Pictures Using Word 2013

Anonymous
2014-06-20T00:11:41+00:00

I have been experimenting and researching for several days to figure out how to do a Mail Merge that includes variable I edited my original post after finding very helpful tips from Paul, Doug, and Graham. I’m preparing a merge document that will be manually e-mailed to parents who have a child enrolled in a preschool. My screen shots have information blocked for privacy. I have to add FN into my hotkey combinations for them to work with my keyboard. Do not use FN if your keyboard does not require you to press it to activate the function keys.

Main Document: My main document includes merge fields for a child’s name and child’s picture.

Data Source: I used two fields in an Excel data source file: "Pic" to hold the names of each picture and "Path" to hold the name of the path to that *jpg picture. Note the paths include double backslashes. Make sure you have added them in the same pattern for your path. I advise keeping picture names short with no spaces. 

 

  1. Reconnect to your Data Source file: from the Start Mail Merge group, click Select Recipients, Use an Existing List, browse to your Excel Data Source file. [I think if you wait to do this until after step 17, you get the error with the link to picture not working.]
  2. Press FN+ALT+F9 to display field codes.
  3. Click in the square in the banner on the right where the picture will be inserted:
    1. Press CTRL+FN+F9 to insert a pair of field boundaries.
    2. Click directly after the first opening field boundary and type INCLUDEPICTURE; click just after the first space following the typed text.
    3. Press CTRL+FN+F9 to insert a second pair of field boundaries.
    4. Click directly after the second opening field boundary, and type IF TRUE; click just after the first space following the typed text; type " (quotation marks).
    5. From the MAILINGS tab, Write & Insert Fields group, click Insert Merge Field list arrow; click Path.
    6. Type / (a forward slash).
    7. From the MAILINGS tab, Write & Insert Fields group, click Insert Merge Field list arrow; click Pic.
    8. Type " (quotation marks).
    9. Delete the space after the quotation marks you just typed and the closing field boundary.
    10. Click just before the last closing filed boundary; type \d(backslash d).
      1. The field should look like this:

  1. Reconnect to your Data Source file: from the Start Mail Merge group, click Select Recipients, Use an Existing List, browse to your Excel Data Source file just to be sure you’re linked. Save the file.
  2. Press FN+ALT+F9 to toggle field code display off.
  3. From the MAILINGS tab, Preview Results group, click Preview Results.
  4. From the MAILINGS tab, Finish group, click the Finish & Merge button; click Send Email Messages.
Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

40 answers

Sort by: Most helpful
  1. Paul Edstein 82,861 Reputation points Volunteer Moderator
    2014-06-20T00:35:03+00:00

    I don't know why anyone would say it isn't possible or that the .doc format is required. Neither proposition is true.

    To insert variable images in a mailmerge, you need to embed the relevant mailmerge field in a INCLUDEPICTURE field. However, there are some issues with this that make the process less straightforward than one might expect. For example, when embedding a mailmerge field in an INCLUDEPICTURE field for the purpose of merging graphics:

    1. the file paths to the fields need to have the separators expressed as '\' or '/' instead of the usual '';

    2. the pictures usually won't show until you refresh the fields (eg Ctrl-A, then F9) in the output document after completing the merge; and

    3. even after updating the images, they remain linked to the image files, which can be an issue if you later delete the image or you need to send the merged output to someone else.

    The following field construction addresses all three issues (i.e. you don't need to do anything special to the paths, or refresh the fields, and they'll no longer be linked to the source files):

    {IF{INCLUDEPICTURE {IF TRUE "C:\Users\My Document Path\Pictures\«Image»"} \d} {INCLUDEPICTURE {IF TRUE "C:\Users\My Document Path\Pictures\«Image»"} \d}}

    or:

    {IF{INCLUDEPICTURE {IF TRUE "C:\Users\My Document Path\Pictures{MERGEFIELD Image}"} \d} {INCLUDEPICTURE {IF TRUE "C:\Users\My Document Path\Pictures{MERGEFIELD Image}"} \d}}

    After running a mailmerge coded this way, you'll have the correct, unlinked image for each record.

    This form of field construction can be very useful where the filepath for the images is held in the mailmerge data source, in which case you could use:

    {IF{INCLUDEPICTURE {IF TRUE "«FilePath»\«Image»"} \d} {INCLUDEPICTURE {IF TRUE "«FilePath»\«Image»"} \d}}

    or:

    {IF{INCLUDEPICTURE {IF TRUE "{MERGEFIELD FilePath}{MERGEFIELD Image}"} \d} {INCLUDEPICTURE {IF TRUE "{MERGEFIELD FilePath}{MERGEFIELD Image}"} \d}}

    Note 1 : You need a path separator between the filepath mergefield and the image mergefield. If that separator is included in the source data, it can be omitted from the field above construction but leaving it there has no adverse effects

    either.

    If you can be sure the pictures will always be in the same folder as the mailmerge main document, you can incorporate a FILENAME field thus:

    {IF{INCLUDEPICTURE {IF TRUE "{FILENAME \p}..{MERGEFIELD Image}"} \d} {INCLUDEPICTURE {IF TRUE "{FILENAME \p}..{MERGEFIELD Image}"} \d}}

    or:

    {IF{INCLUDEPICTURE {IF TRUE "{FILENAME \p}..\«Image»"} \d} {INCLUDEPICTURE {IF TRUE "{FILENAME \p}..\«Image»"} \d}}

    If the path data are included with in the image field, you can use:

    {IF{INCLUDEPICTURE {IF TRUE «Image»} \d} {INCLUDEPICTURE {IF TRUE «Image»} \d}}

    or:

    {IF{INCLUDEPICTURE {IF TRUE {MERGEFIELD Image}} \d} {INCLUDEPICTURE {IF TRUE {MERGEFIELD Image}} \d}}

    For what it's worth, *provided* the path has the separators expressed as '\' or '/', you can retain the links by omitting the all-encompassing IF test and the images will display correctly without the need to refresh the fields after completing the merge. For example:

    {INCLUDEPICTURE {IF TRUE "C:\Users\My Document Path\Pictures\«Image»"} \d}

    Note 2: The field brace pairs (i.e. '{ }') for the above example are created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practicable to add them via any of the standard Word dialogues. Likewise, you can't type or copy & paste the chevrons (i.e. '« »') - they're part of the actual mergefields, which you can insert from the mailmerge toolbar. The spaces represented in the field construction are all required.

    Was this answer helpful?

    20+ people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2014-06-20T00:41:07+00:00

    Thank you, Paul. However, I doubt I would be able to follow your directions to test the steps. That said, I'm sure there are others out there with enough familiarity with all those lines of codes you included and know Word merge enough to copy/paste or do whatever needs doing to get the merge to work. In any case, hopefully my post and yours are valuable to others. I didn't find anything relevant or recent in this regard when I searched the Microsoft Community. This is not a common application for Word merge and I own many Word books--none of them even mentioned it.

    Was this answer helpful?

    10+ people found this answer helpful.
    0 comments No comments
  3. Anonymous
    2016-03-28T07:46:57+00:00

    Good day all,

    I was also struggling with this feature (until tonight).

    I am using Office 365 (Word 2016 and Excel 2016).

    I am trying to put a unique picture and unique QR code on a business card using mail merge from an excel file.

    My Excel headers and sample data are as follows:

    CIN Last_Name First_Name Merged_Name Photo
    1195 Beaud Jeremo 1195224 Beaud Jeremo G:\Photo\logo.jpg
    1348 Boon Paka 1348449 Boon Paka G:\Photo\1348 Boon Paka.jpg
    1594 Buck Leslie 1594043 Buck Leslie G:\Photo\1594 Buck Leslie.jpg

    I am successfully using DISPLAYBARCODE as follows:

    { DISPLAYBARCODE "{ MERGEFIELD Merged_Name }" \s 80 }

    I am now successfully using INCLUDEPICTURE using:

    { INCLUDEPICTURE { IF TRUE "{ MERGEFIELD Photo }" \* MERGEFORMAT \d }}

    It took me more than several hours to sort this out, but I finally got it working.

    Darcy

    Was this answer helpful?

    6 people found this answer helpful.
    0 comments No comments
  4. Anonymous
    2016-01-22T14:55:54+00:00

    Hi Paul, 

    I have seen your comment on this issue on a number of thread and I have tried to make it work. I am using the extended version to try and address the 3 points you mention. Here is an example of one of my statement: 

    {IF {INCLUDEPICTURE {IF TRUE "{ MERGEFIELD PictureLocation }"} \d}{ INCLUDEPICTURE {IF TRUE "{ MERGEFIELD PictureLocation }"} \d}}

    (Note: The "MERGEFIELD PictureLocation" contains the filepath and image name)

    This works and indeed addresses the first two points. But after the merge is complete and pictures can be seen, when I then save the merged file and reopen, or if I change the location of the merged file and reopen, it no longer displays the picture but instead shows:

    { INCLUDEPICTURE \d"C:\Users\temborowski\Desktop\Picture Mail Merge\Picture Library\cycle length.jpg"\* MERGEFORMATINET }

    Any ideas why and how to resolve?

    Thanks,

    Temi

    Was this answer helpful?

    4 people found this answer helpful.
    0 comments No comments
  5. Paul Edstein 82,861 Reputation points Volunteer Moderator
    2014-06-20T00:52:10+00:00

    I've posted the same advice (and variations of it) here and on other forums numerous times, and others have posted similar advice too. See also: http://www.gmayor.com/mail_merge_graphics.htm

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments