2 Correct Ways to Change a Bookmark Name in Your Word Document

In the bellowing article, we would like to provide you with 2 correct ways to change a bookmark name in your Word document.

While drafting a long Word document, bookmarks and cross-references can become our best friend by saving us a lot of time re-explaining the same point. However, unexpected issue can occur. For example, if you change a bookmark name and update the cross-references, you will certainly fail and end with reference errors such as bellow:Reference error

The reason is that the time you alter the bookmark name, you accidentally deleted the bookmark itself. Now we will show you 2 methods to address this problem.

Method 1: Change the Bookmark Name and Update Cross-references Manually

  1. To start off, click “Insert” tab then click “Bookmark” in “Links” group.Click "Insert"->Click "Bookmark"
  2. Next click to select the target bookmark and click “Go To”.
  3. You will see the bookmark texts are in selection by then. Click “Delete”.Choose Bookmark->Click "Go To"->Click "Delete"
  4. Then enter a new bookmark name and click “Add”.
  5. Press “Alt+ F9” to show the field codes.Press "Alt+ F9" to show field codes
  6. In case you have multiple cross-references, we recommend you using “Find and Replace” function. Just press “Ctrl+ H” to invoke the “Find and Replace” dialog box.
  7. Now enter “REF DWORDR” in “Find what” text box and “REF DWORDR2” in the “Replace with” one. “DWORDR” is the original bookmark name and “DWORDR2” is the new one.
  8. Next click “Replace All”.Enter bookmark names ->Click "Replace All"
  9. Close the “Find and Replace” box and press “Alt+ F9” to show the reference contents again.
  10. Then press “Ctrl+ A” and “F9” next to update all fields in the document.

When you move cursor over the cross-reference, you can see the new bookmark name on the screen tip box.The effect

Method 2: Change the Bookmark Name and Update Cross-references via VBA

  1. Firstly, press “Alt+ F11” to trigger VBA editor.
  2. Go to the “Normal” project to insert a new module by clicking “Insert” tab first.
  3. Then choose “Module” on its drop-down menu.Click "Normal"->Click "Insert"->Click "Module"
  4. Double click on the newly created module to open the editing space on the right side.
  5. Next paste the following macro there:
Sub ChangeTheBookMarkNameAndUpdateCrossReference()
  Dim strBookMarkName As String
  Dim strNewName As String
  Dim objBookMarkRange As Range
  Dim objField As Field
  Dim strFieldCode As String
  '  Rename the bookmark name.
  strBookMarkName = InputBox("Enter the bookmark name which you want to change", "BookMark Name", "For example: DWORDR")
  strNewName = InputBox("Enter the New bookmark Name", "New Bookmark Name", "For example: New text")
  With ActiveDocument
    If .Bookmarks.Exists(strBookMarkName) Then
      Set objBookMarkRange = .Bookmarks(strBookMarkName).Range
      .Bookmarks.Add Name:=strNewName, Range:=objBookMarkRange
      '  Update the cross-reference
      If .Fields.Count >= 1 Then
        For Each objField In .Fields
          strFieldCode = objField.Code.Text
          If strFieldCode = " REF " & strBookMarkName & " \h " Then
            objField.Code.Text = Replace(strFieldCode, strBookMarkName, strNewName, , 1, vbTextCompare)
            MsgBox ("Code = " & objField.Code & vbCr & "Result = " & objField.Result & vbCr)
          End If 
        Next objField 
      End If
      MsgBox ("The Bookmark: " & strBookMarkName & " is not founded.")
    End If
  End With

  Set objBookMarkRange = Nothing
End Sub
  1. Click “Run” or press “F5”.Paste Codes->Click "Run"
  2. Now enter the original bookmark name on the first box popping up and click “OK”.Enter the original name->Click "OK"
  3. Enter the new name on the second and click “OK”.Enter new bookmark name->Click "OK"

Lastly, there will be a box showing you the result.Box showing the result

Look after Word Documents

The cost of a corrupted Word document is not confined to staggering business loss but also make people emotionally distraught. Thus it’s extremely necessary to take preventive measures to bypass the unlucky such as backing up documents.

Author Introduction:

Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including xlsx repair and pdf repair software products. For more information visit www.datanumen.com

Leave a Reply

Your email address will not be published. Required fields are marked *