Renaming a bookmark in Word 2010

Is there a simpler or more effective way to rename bookmarks in Word documents?

There is no rename function built-in to Word. There are a couple of options to work around this lack:

  1. Use an Add-in.

  2. Use VBA.


Add-in Solution

Use the Bookmark Tool Add-In

It offers a friendly user interface for doing everything the standard Bookmark Dialog box will do plus much more.

Bookmark Tool was developed for Word 2003. It is wholly functional with Word 2007/2010.

...

With the "Add/Rename Bookmark" section, adding bookmarks is a breeze.

  • As in the standard dialog, you simply select text, type a name in the field, and click "Add."
  • Unlike the standard dialog, Bookmark Tool restricts key entry to valid bookmark name characters and alerts you if you attempt to create a duplicate bookmark name.
  • You can also use this section to rename an existing bookmark.

    enter image description here

Source Bookmark Tool Add-In


VBA solution

There isn't a rename function. You have to delete the old name and mark the range with a new bookmark name. Here's sample VBA code:

Sub ReNameBookMark()
    Dim doc As Word.Document
    Dim rng As Word.Range
    Dim bmk As Word.Bookmark
    Dim inpBookmark, repBookmark, fieldStr As String

    Set doc = Word.ActiveDocument

    inpBookmark = InputBox("Enter bookmark name that you want to be replaced:", "BookMark Replace")
    repBookmark = InputBox("Enter bookmark name replace with:", "BookMark Replace")

    Set rng = doc.Bookmarks(inpBookmark).Range
    Set bmk = doc.Bookmarks(inpBookmark)
    bmk.Delete
    rng.Bookmarks.Add (repBookmark)

    If doc.Fields.Count >= 1 Then
        For i = 1 To doc.Fields.Count
            fieldStr = doc.Fields(i).Code.Text
            If Left(fieldStr, 4) = " REF" Then
                doc.Fields(i).Code.Text = Replace(fieldStr, inpBookmark, repBookmark, , 1, vbTextCompare)
                doc.Fields(i).Update
            End If

            'MsgBox "Code = " & doc.Fields(i).Code & vbCr & "Result = " & doc.Fields(i).Result & vbCr
        Next i
    End If
End Sub

Source Change the "name" of a bookmark not the text of it, with an additional loop to run through the fields in the document to change any that might be referencing the bookmark being renamed.

Care should be taken using this script. For example renaming any bookmarks that are simply named "REF" (or an upper or lower case variant of such) will break ALL references in amusing and unexpected ways. This is meant as an example and rough fix only.

If you want to batch rename multiple bookmarks in one go see Is there a simpler or more effective way to rename bookmarks in Word documents? which also includes sample VBA code.