Collection of bookmarks.

J

Jesper

Hi, is there any command to get a list of names or collection of all the bookmarks in a document.

brgds Jesper, Denmark.
 
H

Helmut Weber

Hi Jesper,
like this:
Sub Makro6()
Dim b As Integer ' bookmarks counter
Dim s As String
Dim oBkm As Bookmark
For b = 1 To ActiveDocument.Bookmarks.Count
' in order from start to end of doc
Set oBkm = ActiveDocument.Range.Bookmarks(b)
s = Format(b, "000 = ")
s = s & oBkm.Name & " "
s = s & oBkm.Range.Text
Debug.Print s
Next
Debug.Print "---"
For b = 1 To ActiveDocument.Bookmarks.Count
' in alphabetical order
Set oBkm = ActiveDocument.Bookmarks(b)
s = Format(b, "000 = ")
s = s & oBkm.Name & " "
s = s & oBkm.Range.Text
Debug.Print s
Next
' or
For Each oBkm In ActiveDocument.Bookmarks
'---
Next
' or
For Each oBkm In ActiveDocument.Range.Bookmarks
'---
Next
' not to mention bookmarks in headers and footers
' etc.
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