How can I view or print all the bookmarks in a word document at o.

C

Cowgirl Up

I am using Word 2003 and would like to view or print all the bookmarks in a
document at one time.

In brief: I use these bookmarks in the code of a audit report automation
program (written in VBA for Word) and need to eleminate a document from which
the program calls. I would like to use some of the bookmarks in another
document and eleminate others. In the past I have had to write each bookmark
out on a piece of paper. This method allows room for a lot of errors. There
has got to be an easier way! Can any one help?
 
P

Peter

Something like this might do the trick:


Dim curdoc As Document
Dim newdoc As Document
Dim bk As Bookmark

Set curdoc = ActiveDocument

Set newdoc = Application.Documents.Add

For Each bk In curdoc.Bookmarks
Call newdoc.Range.InsertAfter(bk.Name & vbNewLine)
Next bk

hth,

-Peter
 
M

macropod

Hi Cowgirl,

The following macro generates a list of all bookmarks at the end of the
active document and displays their contents:



Sub ListBkMrks()
Dim oBkMrk As Bookmark, oBMk As Variant
If ActiveDocument.Bookmarks.Count > 0 Then
For Each oBkMrk In ActiveDocument.Bookmarks
With Selection
.EndKey Unit:=wdStory
.InsertAfter vbCrLf
.InsertAfter oBkMrk.Name & " "
.EndKey Unit:=wdStory
oBMk =
ActiveDocument.Fields.Add(Range:=Selection.Range, Text:= oBkMrk.Name,
PreserveFormatting:=False)
End With
Next oBkMrk
End If
End Sub

Cheers
 

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