Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is it possible to rename multiple bookmarks in standard Word 97-2003 doc file? I just finished a 400 page document, in Word 2010, with several hundred bookmarks that must be renamed and I definitely don't want to go in and rename them manually. I found this Word add-in for enhancing the built-in Word Bookmark Dialog, but can't seem to get it to load properly into my document, if I can get it working it will solve my problem. Until then are there any other straightforward methods for accomplishing this? Maybe this can be accomplished using macros. Right now I'm looking to see if OpenOffice supports batch renaming of bookmarks in a docx file. Help is appreciated.

share|improve this question

migrated from stackoverflow.com Nov 18 '11 at 22:31

This question came from our site for professional and enthusiast programmers.

1 Answer 1

You can do this with a VBA macro in Word. The below macro, which is taken from here (and discussed in greater detail on the Web page), will prepend "NEW_" to each existing bookmark name, but it can be adapted to rename the bookmarks with whatever conventions are desired.

Sub RenameBookmarks()
'  although it does NOT rename them
'  it creates a new one for the same range
'  then deletes the old one

Dim BM_Names()
Dim i As Long
With ActiveDocument
  For i = 1 To .Bookmarks.Count
    ReDim Preserve BM_Names(i)
    BM_Names(i) = .Bookmarks(i).Name
  Next
  For i = 1 To .Bookmarks.Count
    With .Bookmarks(BM_Names(i))
      .Range.Bookmarks.Add Name:="NEW_" & .Name, Range:=.Range
      .Delete
    End With
  Next
End With
End Sub
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.