Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
WordQueen WordQueen is offline
external usenet poster
 
Posts: 1
Default Can I print a list of bookmarks in a document or template?

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?
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Can I print a list of bookmarks in a document or template?

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
Word MVP web site http://word.mvps.org



WordQueen wrote:
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?



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default Can I print a list of bookmarks in a document or template?

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


--
Cheers
macropod
[MVP - Microsoft Word]


"WordQueen" wrote in message ...
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?

  #4   Report Post  
SHNABY SHNABY is offline
Junior Member
 
Posts: 0
Default

Quote:
Originally Posted by WordQueen View Post
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?
Hi WordQueen,
The quickest way to extract a list of bookmark is to run a macro.
The following macro will export all bookmarks within a document to a new document and arrange bookmark names, texts, and page numbers in a table.

Just press "Alt+ F11" to open VBA editor, create a new module and run the following codes:

Sub ExtractBookmarksInADoc()
Dim objBookmark As Bookmark
Dim objTable As Table
Dim nRow As Integer
Dim objDoc As Document, objNewDoc As Document
Dim objParagraph As Paragraph

Set objDoc = ActiveDocument

If objDoc.Bookmarks.Count = 0 Then
MsgBox ("There is no bookmark in this document.")
Else
Set objNewDoc = Documents.Add

Selection.TypeText Text:="Bookmarks in " & "'" & objDoc.Name & "'"

Set objTable = Selection.Tables.Add(Range:=Selection.Range, numrows:=1, numcolumns:=3)
objTable.Borders.Enable = True
nRow = 1

For Each objParagraph In objNewDoc.Paragraphs
If objParagraph.Range.Style = "Caption" Then
objParagraph.Range.Delete
End If
Next objParagraph

With objTable
.Cell(1, 1).Range.Text = "Name"
.Cell(1, 2).Range.Text = "Texts"
.Cell(1, 3).Range.Text = "Page Number"

For Each objBookmark In objDoc.Bookmarks
objTable.Rows.Add
nRow = nRow + 1
.Cell(nRow, 1).Range.Text = objBookmark.Name
.Cell(nRow, 2).Range.Text = objBookmark.Range.Text
.Cell(nRow, 3).Range.Text = objBookmark.Range.Information(wdActiveEndAdjustedP ageNumber)
objDoc.Hyperlinks.Add Anchor:=.Cell(nRow, 3).Range, Address:=objDoc.Name, _
SubAddress:=objBookmark.Name, TextToDisplay:=.Cell(nRow, 3).Range.Text
Next objBookmark
End With
End If
objNewDoc.SaveAs2 FileName:=objDoc.Path & "\" & "Bookmarks in " & objDoc.Name
End Sub


The page numbers are in link, so you can follow them and quickly jump to the bookmark location.

For more detailed information, you can refer to this article:

https://www.datanumen.com/blogs/batc...word-document/

Hope that helps!

SHNABY

Last edited by SHNABY : April 25th 17 at 08:20 AM
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Create an List of bookmarks for my webpage Amy Schmid Microsoft Word Help 1 January 9th 09 12:34 AM
How to print bookmarks in a document Paul Bakker Microsoft Word Help 2 September 6th 07 01:24 PM
List cross-refernces to bookmarks matty_b Microsoft Word Help 1 April 1st 06 08:07 AM
List all bookmarks in a Protected Form Leonard Microsoft Word Help 0 September 16th 05 08:59 PM
Make list of bookmarks in Word a side panel kiraswift Microsoft Word Help 3 July 20th 05 12:25 AM


All times are GMT +1. The time now is 12:10 AM.

Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Copyright 2004-2023 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"