The Set field assigns specific information to a named variable, called a bookmark. For the information to appear in the document, you must insert a Ref field that refers to the bookmark. You can also use the bookmark to process the information invisibly, such as in a macro or in another field, such as an If field.
Syntax
When you view the Set field in your document, the syntax looks like this:
{ SET Bookmark "Text" }
Note: A field code tells the field what to show. Field results are what’s shown in the document after having evaluated the field code. To toggle between viewing the field code and the field code results, press Alt+F9.
Instructions
You can use the Set field in a document or as part of a mail merge.
To use the Set field in a document, do the following:
-
On the Insert tab, in the Text group, click Quick Parts, and then click Field.
-
In the Field names list, select Set.
-
In the Bookmark name list, select the name of a bookmark.
-
In the Text box, type the text that you want to assign to the bookmark.
-
Click OK.
To use the Set field as part of a mail merge, do the following while you are setting up the mail merge:
-
On the Mailings tab, in the Write & Insert Fields group, click Rules, and then click Set Bookmark.
-
In the Bookmark list, select the name of a bookmark.
-
In the Value box, type the text that you want to assign to the bookmark.
Properties
Bookmark
The name that stands for the information: a variable — for example, InterestRate.
"Text"
Information that is assigned to the bookmark: a literal value. Enclose text in quotation marks; numbers don't require quotation marks. The information can be the result of a nested field.
Example
In the following example, a document contains the bookmarks EnteredBy, UnitCost, Quantity, SalesTax, and TotalCost. Set fields establish the contents of each of these bookmarks, and Ref fields have been inserted in the document to display the contents of the bookmarks. A numeric picture switch displays the UnitCost and TotalCost values with a currency symbol and two decimal places.
{ SET EnteredBy "Yury Vronsky" }
{ SET UnitCost 25 } { SET Quantity { FILLIN "Enter number of items ordered:" } } { SET SalesTax 10% } { SET TotalCost { = (UnitCost * Quantity) + ((UnitCost * Quantity) * SalesTax) } } This confirms your order of our book. You ordered { REF Quantity } copies at { REF UnitCost \# "$#0.00" } apiece. Including sales tax, the total comes to { REF TotalCost \# "$#0.00" } Thank you for your order, { EnteredBy }If the user types 3 in response to the prompt for the FILLIN field, the resulting document looks like this:
This confirms your order of our book. You ordered 3 copies at $25.00 apiece. Including sales tax, the total comes to $82.50.
Thank you for your order, Yury Vronsky