View Single Post
 
Old 05-25-2011, 09:06 AM
b0x4it b0x4it is offline Windows 7 32bit Office 2010 32bit
Advanced Beginner
 
Join Date: May 2011
Posts: 95
b0x4it is on a distinguished road
Default Putting a bookmark on a REF field in the selection

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?
Reply With Quote