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.
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
Outdoor Edge Landscaping LLC
400 S Morrison Ave
Collinsville IL 62234
(618) 270-5160
landscaping o fallon il
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
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
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.
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!