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:
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
- To start off, click “Insert” tab then click “Bookmark” in “Links” group.
- Next click to select the target bookmark and click “Go To”.
- You will see the bookmark texts are in selection by then. Click “Delete”.
- Then enter a new bookmark name and click “Add”.
- Press “Alt+ F9” to show the field codes.
- 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.
- 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.
- Next click “Replace All”.
- Close the “Find and Replace” box and press “Alt+ F9” to show the reference contents again.
- 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.
Method 2: Change the Bookmark Name and Update Cross-references via VBA
- Firstly, press “Alt+ F11” to trigger VBA editor.
- Go to the “Normal” project to insert a new module by clicking “Insert” tab first.
- Then choose “Module” on its drop-down menu.
- Double click on the newly created module to open the editing space on the right side.
- 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
- Click “Run” or press “F5”.
- Now enter the original bookmark name on the first box popping up and click “OK”.
- Enter the new name on the second and click “OK”.
Lastly, there will be a box showing you 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.
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