Quote:
Originally Posted by laith93
Thank you MR. Charles
Again the above macros work to find and replace normal text anywhere, but do not look for the text of field codes ex: {Seq Appendix \* Arabic}.
Here the sample file you can try to explore what I mean.
|
That page shows how to loop through stories in a document to get to all parts.
Code:
Sub AppendixParens()
' Charles Kenyon using code from Graham Mayor
' October 21, 2021
' https://www.msofficeforums.com/word/47835-putting-parentheses-around-sequence-number-caption-label.html
Dim oStory As range, oFld as Field
On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
Do
For Each oFld In oStory.Fields
If oFld.Type = wdFieldSequence Then
If InStr(1, oFld.Code, "Appendix") > 0 Then
oFld.Result.InsertAfter ")"
oFld.Result.InsertBefore "("
End If
End If
Next oFld
Loop Until oStory Is Nothing
Next
Set oFld = Nothing
Set oStory = Nothing
On Error GoTo -1
End Sub