List of bookmarks

S

Steve Wylie

Is there a way (presumably using VBA, but if Word can do
this itself without VBA, great, but I don't think it can)
that I can get a list or printout of all the bookmarks
present in a document? Sort of a list of the bookmark
names like:

Ch1
Ch2
Ch2a
....etc
etc...

Hope someone can help!

Steve
 
H

Helmut Weber

Hi Steve,
sort of:
Dim oRng As Range
Dim oBkm As Bookmark
For Each oRng In ActiveDocument.StoryRanges
For Each oBkm In oRng.Bookmarks
MsgBox oBkm.Name ' debug.print
' or selection.typetext text:=obkm.name & chr(13)
Next
Next
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
 
J

Jay Freedman

Hi Steve

The following macro will create a new document and fill it with the list of
bookmarks in the current document.

Public Sub ListBookmarks()
Dim oDoc1 As Document
Dim oDoc2 As Document
Dim oBM As Bookmark

Set oDoc1 = ActiveDocument
Set oDoc2 = Documents.Add
oDoc2.Range.Text = "Bookmarks in " & _
oDoc1.FullName & vbCr

For Each oBM In oDoc1.Bookmarks
oDoc2.Range.InsertAfter oBM.Name & vbCr
Next oBM
End Sub

This list will be in alphanumeric order. If you want the list instead to be
in the order of occurrence of the bookmarks in the document, change the For
Each line to

For Each oBM In oDoc1.Range.Bookmarks
 
S

Steve

Thank you for your prompt reply - I'll see how I get on
with your macro and Helmut's response also.

Steve
 

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