How to show all names of bookmarks in documents?

A

avkokin

Hello. Is it possible and if "yes" then how to show in the document
the full list of the names of the bookmarks (if they exist)? Thank you.
 
H

Helmut Weber

Hi Avkokin,

its so simple, I fear,
I did not understand the question:

Sub Macro34ab()
Dim oBkm As Bookmark
For Each oBkm In ActiveDocument.Bookmarks
ActiveDocument.Range.InsertAfter oBkm.Name & vbCrLf
Next
End Sub
 
M

Michael Bednarek

Hello. Is it possible and if "yes" then how to show in the document
the full list of the names of the bookmarks (if they exist)? Thank you.

This might do what you want:

Dim bmkBmk As Bookmark

For Each bmkBmk In ActiveDocument.Bookmarks
Debug.Print bmkBmk.Name
Next bmkBmk
 
A

avkokin

This might do what you want:

  Dim bmkBmk As Bookmark

  For Each bmkBmk In ActiveDocument.Bookmarks
    Debug.Print bmkBmk.Name
  Next bmkBmk

Thank you very much.
 
A

avkokin

Hi Avkokin,

its so simple, I fear,
I did not understand the question:

Sub Macro34ab()
Dim oBkm As Bookmark
For Each oBkm In ActiveDocument.Bookmarks
ActiveDocument.Range.InsertAfter oBkm.Name & vbCrLf
Next
End Sub

--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000 (german versions)

Helmut, if possible how to show these bookmarks (name of bookmarks) as
hyperlinks?
 
H

Helmut Weber

Hi Avkokin,

I guess you mean that:

Sub Test6666a()
Dim oBkm As Bookmark
' make sure that there is an empty paragraph
' at the doc's end
ActiveDocument.Range.InsertAfter vbCrLf
For Each oBkm In ActiveDocument.Bookmarks
ActiveDocument.Hyperlinks.Add _
Anchor:=ActiveDocument.Paragraphs.Last.Range, _
SubAddress:=oBkm.Name, _
ScreenTip:="", _
TextToDisplay:=oBkm.Name
ActiveDocument.Range.InsertAfter vbCrLf
Next
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

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