reference errors after changing bookmark text

Oerkey

Right off the assembly line
Hey,

It's about a paper which I'm writing. I add a bookmark for a product and create a few cross-references for it. But I find that I need to change the bookmark text as the product name is update. It seems I once I change the bookmark text, the bookmark will be deleted, so that all cross-references will get reference errors.

So I want to know how can I just change the text of a bookmark and also update the cross-reference automatically withou the error? Any ideas?
 

Locas

Right off the assembly line
Hello.

You have two ways to do that:

1. Replace Bookmark Text inside its Field
Just put cursor inside the bookmark text to enter new contents there. After this, delete the original text. Then press “Ctrl+ A” to select the entire document and press “F9” to update references.

2. Use VBA

Code:
Sub ChangeTheBookMarkTextAndUpdateCrossReference()
  Dim strBookMarkName As String
  Dim strNewText As String
  Dim objBookMarkRange As Range
 
  '  Input the bookmark name and text that you want to change.
  strBookMarkName = InputBox("Enter the bookmark name which you want to change it's text", "BookMark Name", "For example: DWORDR")
  strNewText = InputBox("Enter the bookmark text which you want to change", "New Bookmark Text", "For example: New text")
  With ActiveDocument
    If .Bookmarks.Exists(strBookMarkName) Then
      Set objBookMarkRange = .Bookmarks(strBookMarkName).Range
      objBookMarkRange.Text = strNewText
      .Bookmarks.Add Name:=strBookMarkName, Range:=objBookMarkRange
      .Fields.Update
    Else
      MsgBox ("The Bookmark: " & strBookMarkName & " is not founded.")
    End If
  End With
  Set objBookMarkRange = Nothing
End Sub

I find the ways at

2 Useful Ways to Prevent Reference Errors Caused by Changing Bookmark Text - Data Recovery Blog

You can check it for more details.
 
Top Bottom