Can I print a list of bookmarks in a document or template?

W

WordQueen

I need to print a list of bookmark names in a template. I can't figure out
how to do so. Any words of wisdom?
 
G

Graham Mayor

You could do it with a macro. The following will list all the bookmarks in a
new document.

Dim aDoc As Document
Dim bDoc As Document
Set aDoc = ActiveDocument
Set bDoc = Documents.Add
For i = 1 To aDoc.Bookmarks.Count
sBn = aDoc.Bookmarks(i).name
bDoc.Range.InsertAfter sBn & vbCr
Next i
bDoc.Activate

http://www.gmayor.com/installing_macro.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

macropod

Hi WordQueen,

The following macro generates a list of all bookmarks at the end of the active document, together with their contents:
Sub ListBkMrks()
Dim oBkMrk As Bookmark
If ActiveDocument.Bookmarks.Count > 0 Then
With Selection
.EndKey Unit:=wdStory
.TypeText Text:=vbCrLf & "Bookmark" & vbTab & "Contents"
For Each oBkMrk In ActiveDocument.Bookmarks
.TypeText Text:=vbCrLf & oBkMrk.Name & vbTab & oBkMrk.Range.Text
Next oBkMrk
End With
End If
End Sub
 

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