Exporting a list of bookmark names

T

tpayne

I need to print, or export to a document, a list of all the bookmark names in a long document. Does anyone know how to do that? Maybe someone has written a macro to do this. It seems like a very useful thing to be able to do. Thanks.
 
S

Shauna Kelly

Hi tpayne

The code below isn't thoroughly tested, but it should do the job. It
creates a new blank document and lists there all the bookmark names in
your currently-open document.

If you're not sure what to do with the macro, see
http://www.gmayor.dsl.pipex.com/installing_macro.htm and
http://www.mvps.org/word/FAQs/MacrosVBA/CreateAMacro.htm

Hope this helps.

Shauna


Option Explicit

Sub ListAllBookmarksInThisFile()
'Shauna Kelly, 13 November 2003
'for microsoft.public.word.docmanagement
'
'List all the bookmark names in the active
'document in a new blank document

Dim oThisDoc As Document
Dim oNewDoc As Document
Dim oBM As Bookmark

Set oThisDoc = ActiveDocument
Set oNewDoc = Documents.Add

oNewDoc.Range.InsertAfter _
"Bookmarks stored in " & oThisDoc.FullName & vbCrLf

For Each oBM In oThisDoc.Bookmarks
oNewDoc.Range.InsertAfter oBM.Name & vbCrLf
Next oBM

End Sub


Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
Melbourne, Australia


tpayne said:
I need to print, or export to a document, a list of all the bookmark
names in a long document. Does anyone know how to do that? Maybe someone
has written a macro to do this. It seems like a very useful thing to be
able to do. Thanks.
 
T

tpayne

Thank you. This is amazing. I have a 343 page document (8 subfiles in a master doc), with over 500 bookmarks, and your macro lists them in less than a second! No problems

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top