I'm working with my paper. Every thing is fine until I find I just add a bookmark with wrong name.
I can delete it and create it again with the new name. But there are quite a few
cross-references to this bookmark. They will be all failed with error if I delete the bookmark. God, do I have to set all cross-references again?
Is there any way that I can just change the bookmark name and auto update all
cross-references to the new bookmark? Thanks in advance.
Turn on thread page Beta
change a bookmark name in Word2010 watch
- Thread Starter
- 19-05-2017 08:51
- 23-05-2017 09:56
For that ， you have two ways to do that.
1. Change the bookmark name from A to B
2. Press “Alt+ F9” to show the field codes
3. Open “Find and Replace” dialog box. enter “REF A ” in “Find what” enter “REF B” in “Find what” , click “Replace All"
4. update all fields in the document
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 = NothingEnd Sub Hope it helps