I'm working on a macro for a document to submit to the FDA. There's a bunch of items that appear many many times in the document and change when you start a new document. There's also a bunch of technical reasons why plain search and replace doesn't work and takes along time to fail.
So I've defined a custom property for each of these items. There's a table at the beginning of the document with the property names in the first column. The user fills in the second column with the desired value. My macro extracts the information from the table and changes the property value, turns off screen updating, then updates all instances of the property:
Code:
Sub UpdateSpecificPropertyFields(FieldName As String)
Dim pRange As Word.Range
Dim oFld As Word.Field
For Each pRange In ActiveDocument.StoryRanges
Do
For Each oFld In pRange.Fields
Select Case oFld.Type
Case wdFieldDocProperty
If InStr(oFld.Code.Text, FieldName) Then
oFld.Update
End If
Case Else
'Do nothing
End Select
Next
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
End Sub
But the instances of the property in the header do not get updated. Help?