eBlue, Sacra Blue Online Magazine
Nov 2002 — Issue 244
eBlue articles
Brian Smither
A Question On…

Brian Smither



Contact Information:
Brian Smither


Mail-Merging Pictures

Q. I have 12 pictures per document, one per page, all the same size, all in the same position, for about 35 documents total. I also have a variable amount of text to go with each picture. Is there a way to arrange them without doing each page individually?

A. Let's do this exercise. We will be using Microsoft Word 97 (along with Excel or Access if you have it) to create a Data Source and a Master Document, and merge the two into a resultant document. If you have Word 2000 or Word XP, your dialog boxes and menu selections may be slightly different. The Master Document will have the necessary fields that will import the images. We are going to assume all images are stored at "D:\IMAGES\" and this path will become part of a field code in the Master Document.

The Data Source
The source for the merge can easily be created in any text editor, word processor, database, or spreadsheet. See Table 1 that can be used as an example. Save the data source as "testdata.doc" and close the document.

Table 1
Filename Description
fentoncat.jpg This Fenton cat with attached fount shows how the figurine was originally pressed. The fount is removed before the cat is put on the market. Only 42 of these were sold through Rosso Wholesale Glass Dealers, Inc., in 2001.
mermaid.jpg This early twentieth-century figurehead demonstrates how mermaids, which were commonly romanticized in literature, began to grace vessels with greater regularity during the twilight years of figurehead carving. Courtesy of Mariner's Museum, Virginia.

The Master Document
You can make a very elaborate Master Document— nothing is holding you back in that regard. But to keep the image placement positioned the same from page to page, you will need to anchor the image to an area of text that doesn't move. There are several problems with this, as the image doesn't actually exist in the document until after several additional steps.

If you explore some of the templates that come with Word, you may notice that some of the graphics cannot be moved. That's because they are actually part of the footer. But this won't work for us because, for whatever reason, images merged into a document are fixated at the "in-line" mode. They won't float to wherever we need them to be.

We need to put them inside something that, once positioned, can be locked. There are three things that might serve our purpose: a frame, a text box, and a table cell. The table cannot actually be locked but if everything else in the document is also in the table, nothing could possibly push it out of alignment. The text box isn't suitable as will be seen later. There is also a square AutoShape but it is as unsuitable as the text box. A frame, however, will do nicely and we will explore this later.

Let's look at tables again. If we create cells that are fixed in size, we can keep the image centered in one such cell, put the description in another, and place additional static decorative material in other cells. See Table 2 for an example.

In each row, we can specify an exact height. Select the second row, click Table, Cell Height and Width…, set Height Exactly to 108 pt. (that's 1.5 inches). Because the cell's size is fixed, the image has to shrink to fit inside. We should set that cell to center the contents both horizontally and vertically in case the image is smaller than the cell's dimensions. This is easily accomplished by clicking the Center Vertically button from the Table Toolbar and the Center button on the Formatting Toolbar. Be sure to leave a cell big enough for the description because overflowed text simply disappears.

Add whatever else we want in the other cells and perhaps the page number field in the footer. Save the Master Document as "testmaster.doc" but don't close it yet. We still need to add merge fields while under the Mail Merge Wizard's control.

Table 2

Nov 2002
Sample Merge
Master Document

«Filename»
                                                                   «Description»                                                                  

The Merge
Begin the Mail Merge Wizard (Tools, Mail Merge...). For step one, choose the current document and for step two, open the data file we created earlier. The Mail Merge Wizard will now claim that there are no merge fields found and we are given the opportunity to add some. Note a new toolbar is added to the top ranks: the Mail Merge Toolbar.

Be aware that we cannot simply type what look like fields into the document. We must let Word insert them for us. With the text cursor (others call it the "insertion point cursor") in the cell where we want the picture to be placed, click Insert, Field…, then select "IncludePicture" from the right-side list of items. That field name will be entered on an editing bar where we will also add the path to the directory containing the images. The path must be in quotes and double backslashes be used. Click OK. This regular field should now look like (Press Shift-F9 if necessary):

{ INCLUDEPICTURE "D:\\IMAGES\\" \* MERGEFORMAT }

We didn't enter the actual filename in the field as that comes from the source file. Place the text cursor between the last pair of double backslashes and the quote mark. On the Mail Merge Toolbar, click the Insert Merge Field button, then select the "Filename" list item. With the text cursor in the cell where we want the description to be placed, again click the Insert Merge Field button, then select the "Description" list item.

The appearance of the field codes may be different in your exercise than they appear in this article. That's because there are two views mail mergefield codes can take: a short <<chevron>> version and a longer {MERGEFIELD} version. The views are switched by checking the Tools, Options, View, "Field Codes" box. Regular fields (other than mail mergefields) also have two views: the actual data or the {FIELDNAME} version. Since there is no data yet available for the IncludeFile field, there will either be a completely blank invisible box or, in some cases, absolutely nothing at all. The fields should now look like:

{ INCLUDEPICTURE "D:\\IMAGES\\{ MERGEFIELD Filename }" \* MERGEFORMAT }

We can save this Master Document now as we are ready for the third step in the merging process. Realize that neither the Master Document nor the Data Source is changed in any way during the merge process. A separate third document is generated based on the Master Document but containing the information from the Data Source. (Or you can send directly to the printer. We don't want to do that as will be explained shortly.)

Before we perform the actual merge operation, let's look at the other options we had in controlling the placement of the image on the page: the text box and the frame.

The text box is a very versatile object but has one very critical flaw— it is a segregated entity detached from the text layer. Hence, certain kinds of things simply won't work in it, such as: multiple columns, a table of contents, a page or section number field, comment marks, or anything else that links to text outside the box. The specific reason we don't want to use a textbox for this project (although we actually could) is because textbox contents are not selected when we Select All (Edit, Select All, or CTRL-A). This is undesirable, as will be shown shortly.

The frame is a relatively unknown Word feature. Before the introduction of text boxes in Word 97, frames were employed in Word 6 and Word 95 for callouts and sidebars, and they are specifically used in all versions of Word for "drop caps." They aren't as versatile as text boxes and there's no guarantee that they will remain in future versions of Word. They are still available in Word 2000 but I have no knowledge if they still exist in Word XP [Ed. Note: Frames still exist in Word 2002, in Office XP.].

Because frame usage yielded to text boxes, we must place the frame in the document by way of the text box. So, click Insert, Text box, and swipe the mouse cursor across the document where you want the box to be positioned. (If you didn't get the position quite right, use the sizing handles located on the periphery of the box.) With the text box selected, click Format, Text box, click the Text box tab at the top of the Format dialog box, then click the "Convert to Frame" button. Click OK to the warning message. [Ed. Note: These instructions also work in Word XP.]

Let's see what we need to do about the formatting of the frame: click Format, Frame…, and select how we want other text to flow around it. We also want the frame to stay fixed in place (by default, it moves in sync with the nearest paragraph mark), so uncheck "Move with text" and check "Lock Anchor." Insert the field codes into the frame as was detailed earlier.

The Result
Return to the Mail Merge Wizard and execute step three. We want to merge to a new document because not all fields are processed during the merge. What will happen is that a new, unnamed document gets created; each page contains a copy of the Master Document with only some of the mail merge data fields filled in. To fix this, the InsertPicture fields need to be "updated." To update all fields throughout the entire document, type Ctrl-A, F9, then, if necessary, Shift-F9. That's "Select All" (remember, text boxes aren't included in Select All), Update Field, then, depending how your document is set to show fields, View/Hide Field Code.


Nov 2002
Sample Merge
Master Document
This Fenton cat with attached fount shows how the figurine was originally pressed. The fount is removed before the cat is put on the market. Only 42 of these were sold through Rosso Wholesale Glass Dealers, Inc., in 2001.
Page 1


Nov 2002
Sample Merge
Master Document
This early twentieth-century figurehead demonstrates how mermaids, which were commonly romanticized in literature, began to grace vessels with greater regularity during the twilight years of figurehead carving. Courtesy of Mariner's Museum, Virginia.
Page 2

Save your new publication and print when ready.

Depending on your needs, the source file might exist in an Excel spreadsheet or Access database— this exercise still works.

eBlue articles
This page prepared by:

Brian Smither

Copyright © 2002 Sacramento PC Users Group, Inc. All rights reserved.
Read our disclaimer and copyright page for more information.