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(strBookMarkName).Delete
      .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)
            objField.Update
            MsgBox ("Code = " & objField.Code & vbCr & "Result = " & objField.Result & vbCr)
          End If 
        Next objField 
      End If
    Else
      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

18 responses to “2 Correct Ways to Change a Bookmark Name in Your Word Document”

  1. Wow, awesome weblog layout! How long have you been running a blog for?
    you make blogging look easy. The total look of your website is
    great, let alone the content material! You can see similar:
    Intellara.top and here Intellara.top

  2. Hi,
    Thanks a lot.
    When running the model, the bookmark name updates, but the cross references break.
    Is there a way to resolve this?
    Thanks!!!
    Roni

  3. Great article! I thoroughly enjoyed reading
    it. The information was insightful and well-presented.
    Your writing style made it easy to follow and understand.
    I particularly appreciated the practical examples and real-world applications.
    Thank you for sharing your expertise and taking the time to create such a
    valuable resource.
    3rd Party Logistic Services
    in Las Vegas

  4. What you posted was actually very reasonable.
    However, think on this, what if you were to create a awesome headline?
    I mean, I don’t wish to tell you how to run your blog, however suppose you added a title to
    maybe grab a person’s attention? I mean 2 Correct Ways to Change a
    Bookmark Name in Your Word Document is kinda boring.
    You could glance at Yahoo’s home page and note how they create post headlines to get viewers to click.
    You might add a related video or a picture or two
    to get readers excited about what you’ve got to say.

    Just my opinion, it might make your posts a little bit more interesting.

  5. Thanks so much for this solution. It helped me a lot.

    I made one change, since there was some slight difference in my ref field syntax that caused it not to match exactly. This changed line, about half way through your script, solved the problem:

    Instead of:
    If strFieldCode = ” REF ” & strBookMarkName & ” \h ” Then

    I used
    If InStr(strFieldCode, strBookMarkName) Then

    Thanks again!

Leave a Reply

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