Hi KC:
Elliot and Bob are both correct. However, there are multiple places a Word
document can have fields. The Keystrokes only update the "Text Story" you
happen to be in.
In other words, it won't do the headers and footers in each section, like
you would hope it would.
This will:
Public Sub FieldsUpdateAll()
Dim FieldID As Long
Dim aStory As Range
For Each aStory In ActiveDocument.StoryRanges
FieldID = aStory.Fields.Update
If FieldID <> 0 Then
aStory.Fields(FieldID).Select
MsgBox "Field " & aStory.Fields(FieldID).Code.Text & _
" has an error", vbExclamation
End
End If
Next ' aStory
End Sub
If you beg and plead, one of the kindly ApleScript coders in here will
convert that to AppleScript for you.
All it does is loop through all the text stories in the document updating
fields. It wills top at the first field that won't update due to an error
and select it, so you can see where the little urchin is!
This was coded for Word 2000 originally. In Word 2007, a field can
potentially return "-1" if the document is corrupt. There's nothing wrong
with the field in that case, it's the document that's bad.
You can deal with this one of two ways:
1) Change If FieldID <> 0 to If FieldID > 0... This will enable you to
ignore the error and get the document out the door. If the corruption gets
bad enough, Word will crash so you will know to fix it when that happens
2) Change the macro to throw up an error message and stop, such as "The
Document is Corrupt". Then you have to Maggie (de-corrupt) the document.
Hope this helps
Hello KC -
In addition to Elliott's reply there's an additional keystroke assigned by
default for the UpdateFields command:
Shift+Option+Command+U
You really don't have to be a contortionist to use it
HTH |:>)
Bob Jones
[MVP] Office:Mac
--
Don't wait for your answer, click here:
http://www.word.mvps.org/
Please reply in the group. Please do NOT email me unless I ask you to.
John McGhie, Microsoft MVP, Word and Word:Mac
Sydney, Australia. mailto:
[email protected]