I am trying to find a REF field in the selected text and adding a bookmark to it using this code:
Code:
Sub AddBookmark()
Dim oStoryRng As Range
Dim oFld As Field
For Each oFld In Selection.Fields
If oFld.Type = wdFieldRef Then
ActiveDocument.Bookmarks.Add Range:=oFld, Name:="test"
oFld.Update
End If
Next oFld
End Sub
But when I select the text that includes the field and then run this code, nothing happens and no bookmark is added. Would you please let me know what is wrong with this code?