Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]() Quote:
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 | |
|
|
![]() |
||||
Thread | Forum | |||
Create an List of bookmarks for my webpage | Microsoft Word Help | |||
How to print bookmarks in a document | Microsoft Word Help | |||
List cross-refernces to bookmarks | Microsoft Word Help | |||
List all bookmarks in a Protected Form | Microsoft Word Help | |||
Make list of bookmarks in Word a side panel | Microsoft Word Help |