overview bookmarks

S

SoftwareTester

I want to create a list (like a TOC) containing all bookmarks making it
possible to navigate to those bookmarks from that "TOB"

How do i do that?
 
P

Pesach Shelnitz

Hi,

You don't need VBA code to do this. Press Ctrl+G. In the Go to what list,
select Bookmark, and expand the drop down list.
 
M

macropod

Hi SoftwareTester,

Try:
Sub ListBkMrks()
Dim oBkMrk As Bookmark
If ActiveDocument.Bookmarks.Count > 0 Then
With Selection
.EndKey wdStory
.TypeText vbCrLf & "Bookmark" & vbTab & "Page" & vbTab & "Contents"
For Each oBkMrk In ActiveDocument.Bookmarks
.TypeText vbCrLf & oBkMrk.Name & vbTab
.Fields.Add Selection.Range, wdFieldPageRef, oBkMrk.Name, False
.TypeText vbTab & oBkMrk.Range.Text
Next oBkMrk
End With
End If
End Sub
 
G

Gordon Bentley-Mix on news.microsoft.com

The information that Pesach has given you is quite correct. However, if you
really want a "Table of Bookmarks", I believe your only option is to create
(and maintain) one manually. This can be done using cross-references, but
note that as you add bookmarks to your document, you will need to add the new
bookmarks to the "TOB", which may be somewhat time consuming. In addition, it
might require a bit of "hoop-jumping" to to make this TOB look like a TOC
with page numbers, dot leaders, etc., but a correctly defined Style might be
quite helpful in this regard.

Alternatively, you may be able to do something with TC fields inserted
before each bookmark. This would allow the TOB to be build automatically, but
again a bit of fiddling might be required to achieve the desired result -
especially if the document already contains a TOC built using Headings.

And since you asked this question in the Word programming (i.e. macros/VBA)
forum, I'm sure there's a way to do this all using code. However, until you
confirm that you actually *do* want an automated solution, I'm a bit hesitant
to put a lot of effort into developing one. And if you do want to automate
the process using VBA, my first suggestion would be to have a stab at it
yourself. Work out the process manually and then use the macro recorder to
get you started, and post back if you run into problems.
--
Cheers!

Gordon Bentley-Mix
Word MVP

Please post all follow-ups to the newsgroup.

Read the original version of this post in the Office Discussion Groups - no
membership required!
 
E

EBMurf

macropod,

Your ListBkMrks example is great. Could you point to how you might enhance
it to allow the user to click on the page number field and hyperlink to the
actual page? I'm specifically interested in how to program this process for
an index.

Really appreciate yours and all of the MVPs help

Dave

macropod said:
Hi SoftwareTester,

Try:
Sub ListBkMrks()
Dim oBkMrk As Bookmark
If ActiveDocument.Bookmarks.Count > 0 Then
With Selection
.EndKey wdStory
.TypeText vbCrLf & "Bookmark" & vbTab & "Page" & vbTab & "Contents"
For Each oBkMrk In ActiveDocument.Bookmarks
.TypeText vbCrLf & oBkMrk.Name & vbTab
.Fields.Add Selection.Range, wdFieldPageRef, oBkMrk.Name, False
.TypeText vbTab & oBkMrk.Range.Text
Next oBkMrk
End With
End If
End Sub

--
Cheers
macropod
[Microsoft MVP - Word]


SoftwareTester said:
I want to create a list (like a TOC) containing all bookmarks making it
possible to navigate to those bookmarks from that "TOB"

How do i do that?

.
 
M

macropod

Hi EBMurf,

Change:
..Fields.Add Selection.Range, wdFieldPageRef, oBkMrk.Name, False
to:
..Fields.Add Selection.Range, wdFieldPageRef, oBkMrk.Name & " \h", False

--
Cheers
macropod
[Microsoft MVP - Word]


EBMurf said:
macropod,

Your ListBkMrks example is great. Could you point to how you might enhance
it to allow the user to click on the page number field and hyperlink to the
actual page? I'm specifically interested in how to program this process for
an index.

Really appreciate yours and all of the MVPs help

Dave

macropod said:
Hi SoftwareTester,

Try:
Sub ListBkMrks()
Dim oBkMrk As Bookmark
If ActiveDocument.Bookmarks.Count > 0 Then
With Selection
.EndKey wdStory
.TypeText vbCrLf & "Bookmark" & vbTab & "Page" & vbTab & "Contents"
For Each oBkMrk In ActiveDocument.Bookmarks
.TypeText vbCrLf & oBkMrk.Name & vbTab
.Fields.Add Selection.Range, wdFieldPageRef, oBkMrk.Name, False
.TypeText vbTab & oBkMrk.Range.Text
Next oBkMrk
End With
End If
End Sub

--
Cheers
macropod
[Microsoft MVP - Word]


SoftwareTester said:
I want to create a list (like a TOC) containing all bookmarks making it
possible to navigate to those bookmarks from that "TOB"

How do i do that?

.
 

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