What a crock! How badly documented can a facility be? There are lots of tutorials on the basics of Microsoft Mail Merge, but there is a dearth of information for the INCLUDEPICTURE facility to include images, especially if the images are retrieved from a link/url.
That said, I needed to use it for a project to create a document that plucks up variables from a spreadsheet and drops them into a pretty template for each page. I wrote this note so that the next time I need to revise the document (and stumble over this process), I’ll have these notes. I’m not claiming this is the only way/best way, just that it worked for me. I think I described everything, but please let me know in the comments if I’ve missed something.
I had the following hassles:
- Word uses voodoo magic to accomplish this. [The documentation for how to include images in a mailmerge document is terrible (at least, my google-fu wasn’t strong enough) and it’s worse for images specified by URLs.]
- You need to use (poorly-documented) keyboard commands to type the commands
- Once I had images inserted into the document, I needed to figure out how to adjust their size.
I succeeded – here’s what I did…
- Create an Excel spreadsheet with links (URLs) to the desired images.
- The Excel document should have headers in the first row that describe the data. If you’re retrieving images from a website, you’ll need a field with the links.
- Create a mailmerge document in Word. To do this:
- New Document, then from the Ribbon:
- Click the Mailings tab
- Click Start Mail Merge and choose Letters
- Click Select Recipients – you’ll need to choose the Excel document (and proper tab) that has the data to be merged
- Ignore the “Filter recipients…” stuff
- Click “Insert Merge Field” in the Ribbon and select your fields. The field name appears within «…».
- They’re voodoo magic. They’re kind of cool. When you click the Preview Results button (in the Ribbon), you’ll see your mail merge results, with substitutions of the live data for your
«variables»
- Click Preview Results again to un-preview results and continue editing the document.
More voodoo magic
- If you type
Alt-F9Ctl-F9 (Option-Fn-F9 on Mac), the«variables»
in the document turn into their underlying representation:«Field1»
turns into{ MERGEFIELD Field1 }
It’s editable text. - Don’t do it. It’ll leads to tears. But at least you can see how these are formatted.
Adding an image…
- If you want to insert an image (say, using a URL from that Excel file) you need to do even more voodoo magic. The format is straightforward, but a bit gnarly:
{ INCLUDEPICTURE { MERGEFIELD Name-of-URL-Field } * MERGEFORMAT \d }
- BUT… You can’t just type that string: remember, the
{ ... }
are voodoo magic. - Type Alt-F9 (Cmd-F9 on a Mac) to insert an empty set of braces in the document. Then fill in the text between. If you need a new set of braces inside, just type another Alt-F9 (Cmd-F9) in the right place, and keep typing ’til you enter the correct command.
- Preview Results to see if it’s working.
Resizing an image
- This is Microsoft Word. So there are no rules. Actually, there are, but they’re not known by mere mortals. (Sorry for the snark.)
- The images will be any size they want to be.
- To constrain the images, I found it useful to insert a one-by-one table, and let the content fill the cell. To do this, insert a 1×1 table, and adjust the size of the cell with Table Properties
- I set the Preferred Width (Table tab)
- I set “Specify Height” (Row tab)
- I set “Automatically resize to fit contents” (Options button)
- I then copy/pasted the voodoo magic for the image into the cell.
Finishing up…
- OK – You think you’re almost done. Maybe.
- The Finish and Merge button (in the Ribbon) actually performs the mail merge.
- Edit Individual Documents seems to create a new Word document containing a concatenation of all the mail-merged pages. You can save this (in Word or PDF format) or print it.
- Print Documents will print, or let you save to a PDF.
- You may need to force-load the images, to replace the (single) placeholder image with the right ones. To do this, Select All, then hit F9. You may see a spinner while Word retrieves all the images, but they should all be there.
Additional Thoughts
- I was successful with Microsoft for Mac 2019 using a
.docx
file, despite the fact that Google brings up a lot of (old) advice about using.doc
format, not the (new-fangled).docx
format. - Keymaps: This article gave me a breakthrough, showing how to insert the voodoo magic { } in a document https://wordmvp.com/Mac/FieldsInMacWord.html
- It’s easiest if the images are all the same size, to minimize resizing effort.
- I think the
\d
option of the INCLUDEPICTURE command causes Word not to save the images in the document, making the source file considerably smaller. - I could not find documentation about what the
\* MERGEFORMAT
string does. It works for me. - Let me know in the comments if you find find out more. I’ll update this article.
Great. Thanks for sharing this tutorial! One quick remark, under the Resizing an image you’ll want to make sure the “Automatically resize to fit contents” (Options button)” is unticked to have the image be shaped to the size of the 1×1 table.
Thanks for the tip!
Since this is a step-by-step, keystroke-by-keystroke description, the line “Type Alt-F9 … to insert an empty set of braces in the document” is badly wrong. It’s Ctrl-F9. Took me an hour to figure that out.
Drat. I apologize – I don’t use Windows regularly, so wasn’t able to test this. Sorry to have misled you. (I find it ironic that my site gets a ton of hits on this one article. Why isn’t this documented better?)
One question: for Mac, it appears that there are two critical keyboard commands: Option-Fn-F9 and Cmd-F9. Are there two similar keyboard shortcuts on Windows?