|
 |
|
TIP: An alternative method is first type the text and field
names, select the field name and press CTRL+F9 and repeat for the other
fields. |
|

|
|

|
| - The direct entry method is especially useful for
constructing complex or nested fields. Consider the following nested IF
field used to evaluate and display information about a student: |
|

|
| - Here the IF fields are nested like Chinese eggs.
While this construction can be performed with the menu interface, with
practice it is much easier to simply press CTRL+F9 three times to create the
nested fields and then fill in the data with the keyboard. |
|
| Updating Fields.
Remember that Word is a word processor and not a spreadsheet. Unlike Excel
and other spreadsheet applications, most fields used in Word will not be updated automatically
simply by changing a varialbe. In fact, some fields don't update at
all without specific user action. For more on field update behavior
see the Microsoft Knowledge Base Article 21169:
Which fields are updated
when you open, repaginate, or print document
Lets look at a simple formula field for
summing the results of cell A1 and A2 in a table: |
| The field code |
Display after updating the field result |
Display after changing one of the variables before the
field is updated |
|

|

|

|
|
In simple Word documents after a variable is
changed a user action is
usually required in order of fields to be updated and display accurate results . There are several methods that users may employ to update
fields.
- Update fields individually by mouse right clicking on the field and
selecting "update field"
- Update fields individually by selecting the field and pressing F9
- Update fields globally by selecting all text (including fields) with (CTRL+a) and pressing
F9
- Update fields globally at print execution using the user preference
File>Print>Options> Printing Options>Update Fields
- Update fields globally by shifting to and from "Print Preview."
(File>PrintPreview)
Note: Print options must be set to update fields
- Update fields with a macro. A macro for updating fields in a document is
provided below
|
Sub
UpdateFields()
Dim rngStory As Word.Range
Dim oShp As Word.Shape
For Each rngStory In ActiveDocument.StoryRanges
Do
On Error Resume Next
rngStory.Fields.Update
Select Case rngStory.StoryType
Case 6, 7, 8,
9, 10, 11
If rngStory.ShapeRange.Count > 0 Then
For Each oShp In rngStory.ShapeRange
If oShp.TextFrame.HasText Then
oShp.TextFrame.TextRange.Fields.Update
End If
Next oShp
End If
Case Else
'Do Nothing
End Select
On Error GoTo 0
'Get next linked story (if any)
Set rngStory =
rngStory.NextStoryRange
Loop Until rngStory Is Nothing
Next rngStory
End Sub
|
Bonus Tip: For a more extensive treatment of macros
dealing with the field collection, see:
Field Macos. |
|
Unlinking fields.
Sometimes users wish to enter data based on a field value and then break the
link with that value. A good example and common source of frustration is the { DATE }
field that is inserted by default whenever the menu option Insert>Date and
Time is used. Go ahead and try it. Click Insert>Date and Time
and select a format (Note: for my example I am using the format "MMMM,
d, yyyy"). Now toggle the field code (ALT+F9). The result shown below is
a field code based on the system date. |
|

|
| - { Date } fields are one of
several Word fields that will update automatically when the document is
opened. If you save and close your
practice document and open it next week or next year or next century, the
displayed date will automatically update to the system date on that date!!
A nightmare and great source of frustration as most
users that want a dated document want that date to remain fixed.
- When you generate data based on a field code like
the { Date } field, you can break the link with the field value and
convert the result to plain text by selecting the field and
pressing the keyboard command CTRL+SHIFT+F9. |
Bonus Tip: An alternative
method for inserting the current date (and making it stick) is to uncheck "Update
automatically" in the Insert Date and Time dialog box. This
results in a plain text date stamp being inserted instead of a { Date }
field or you can insert a {
CreateDate } field. |
| There are countless
examples and applications for using Word field code. For more on special formatting in Word fields see
fellow MVP Graham Mayor's
Special Formats
for Word Fields |
|
|
Looking for something else?
|
|
|
|
|