Good morning,

I found this module that works great to update the REF that I have in my
header.
but I was wondering:> If I know the name of the REF can I update the REF
field by Name instead of checking for all Ref fields ?
'---------------------------------------------
Sub RefFieldUpdateAllStory()
' Written by Charles Kyle Kenyon 15 November 2001
' repaired with help from Jezebel 10 December 2004
' All Story Field Updater - Ref fields
Dim oField As Field
Dim oStory As Range
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
Do
For Each oField In oStory.Fields
If oField.Type = wdFieldRef Then
oField.Update
End If
Next oField
Set oStory = oStory.Next
Loop Until oStory Is Nothing
Next oStory
End Sub


Thanks.
Micheline

Re: Updating a REF in a Header by Greg

Greg
Fri May 06 09:09:40 CDT 2005

Micheline,

Yes. One way would be to evaluate the oField.Code.Text like:

Sub RefFieldUpdateAllStory()
Dim oField As Field
Dim oStory As Range
For Each oStory In ActiveDocument.StoryRanges
Do
For Each oField In oStory.Fields
If oField.Type = wdFieldRef Then
If InStr(oField.Code.Text, "Client1") > 0 Then
oField.Update
End If
End If
Next oField
Set oStory = oStory.Next
Loop Until oStory Is Nothing
Next oStory
End Sub

You would need to careful to provide unique REF field names.