Mail Merge Functions
- 4 minutes to read
To specify where data values of the bound data source will appear in a resulting document after mail merge is performed, add special placeholders to a template. These placeholders are called mail merge fields, and they are created via the special functions listed below.
FIELD
The data value from the corresponding field in the data source replaces the FIELD function. Use this function in a cell formula to add a mail merge field to the template using the following syntax.
FIELD("data_field_name")
data_field_name
- The name of the data source field.
FIELDPICTURE
The FIELDPICTURE function retrieves a picture from the specified data field, resizes it according to the function parameters and inserts the picture into the specified position in the merged document.
Apply the FIELDPICTURE function using the following syntax.
FIELDPICTURE("data_field_name", "picture_placement", target_range, [lock_aspect_ratio], [offsetX], [offsetY], [width], [height] )
data_field_name
- The name of the data source field from which the picture is retrieved.
picture_placement
- A case-insensitive string that specifies where a picture should be inserted in the resulting document after mail merging.
range
- The picture is scaled to fit the specified target range.topleft
- The picture is inserted so that its top left corner is located at the specified cell or at the top left cell of the specified range.
target_range
- A reference to the cell range in which a picture should be inserted.
lock_aspect_ratio
- An optional Boolean parameter that indicates whether to maintain a picture’s original aspect ratio. If this parameter is not specified or set to FALSE, the picture’s aspect ratio is locked.
offsetX
andoffsetY
- Values that specify the distance from the left and top of the target range in pixels. These parameters take effect only if picture_placement is set to “range” and lock_aspect_ratio is set to FALSE.
width
andheight
- Values that specify the desired width and height of the picture in pixels.
Examples
=FIELDPICTURE("Picture", "range", A1:B2)
,=FIELDPICTURE("Picture", "range", A1:B2, FALSE)
- Inserts a picture and scales it to fit in the specified range of cells, locking the aspect ratio.
=FIELDPICTURE("Picture", "range", A1:B2, TRUE)
- Inserts a picture to fit in the specified range of cells without locking the aspect ratio.
=FIELDPICTURE("Picture", "range", A1:B2, TRUE)
- Inserts a picture to fit in the specified range of cells without locking the aspect ratio.
=FIELDPICTURE("Picture", "topleft", A1)
,=FIELDPICTURE("Picture", "topleft", A1:B2)
- Inserts a picture so that its top left corner is located at the specified cell or at the top left cell of the specified range.
=FIELDPICTURE("Picture", "topleft", A1, 100)
,=FIELDPICTURE("Picture", "topleft", A1:B2, 100)
- Inserts a picture so that its top left corner is located at the specified cell or at the top left cell of the specified range, and sets the image width to 100 pixels without retaining the aspect ratio.
=FIELDPICTURE("Picture", "topleft", A1, 0, 100)
,=FIELDPICTURE("Picture", "topleft", A1:B2, 0, 100)
- Inserts a picture so that its top left corner is located at the specified cell or at the top left cell of the specified range, and sets the image height to 100 pixels without retaining the aspect ratio.
=FIELDPICTURE("Picture", "topleft", A1, 120, 100)
,=FIELDPICTURE("Picture", "topleft", A1:B2, 120, 100)
- Inserts a picture so that its top left corner is located at the specified cell or at the top left cell of the specified range, and sets the image width to 120 pixels and height to 100 pixels without retaining the aspect ratio.
RANGE
At the template creation stage of the mail merge, you can access the range into which the specified template cell will be expanded in a merged document after a template is repeated for each data record, and inserted one under the other in a single worksheet. To do this, use the RANGE function.
RANGE(abs_cell_reference)
abs_cell_reference
- An absolute reference to a cell in a template that will be copied for each data source record in the resulting worksheet.