Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Printing a Bookmark List.
Written by Allen Wyatt (last updated August 4, 2022)
This tip applies to Word 97, 2000, 2002, and 2003
Word provides a very powerful bookmark facility that allows you to assign names to either individual positions in your document or to text selections. As you work more with Word, and particularly in long documents, it would be helpful to periodically print a list of bookmarks. Unfortunately, Word does not provide an automatic method of printing bookmarks, as it does with other document-related information. The quickest way to print a bookmark list is to just insert the list in your document and then print it. The following VBA macro inserts the bookmark list at the insertion point:
Sub BkMarkList() Dim J as Integer Selection.TypeParagraph Selection.InsertBreak Type:=wdColumnBreak Selection.TypeText Text:="Bookmark list for " Selection.TypeText Text:=ActiveDocument.Name Selection.TypeParagraph For J = 1 To ActiveDocument.Bookmarks.Count Selection.TypeText Text:=Chr(9) Selection.TypeText Text:=ActiveDocument.Bookmarks(J).Name Selection.TypeParagraph Next J Selection.InsertBreak Type:=wdColumnBreak End Sub
When you run the macro, a heading indicating the name of the file will be inserted, followed by each bookmark in the file. These will be in alphabetic order. The bookmark list has a column break before it and after it, as well. You can then print out the single page that contains the bookmark list. When you are done printing, you can delete the bookmark list.
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1019) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Printing a Bookmark List.
Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!
Tables are a great way to organize information in a document. At some point you may want a cell in a table to contain the ...
Discover MoreCreate a bookmark and you may, at some future point, need to delete that bookmark. It's easy to do, as described in this tip.
Discover MoreBookmarks can be a great tool in Word, allowing you to easily remember the location of desired blocks of text. If you ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2017-12-13 23:40:46
jamal
I have a code in Word that extracts all references in the document in a table showing its name, page number, and line.
This is the code:
Sub ListBkMrks()
Application.ScreenUpdating = False
Dim oBkMrk As Bookmark, rng As Range, StrTxt As String, StrStory As String
With ActiveDocument
Set rng = .Range.Characters.Last
If .Bookmarks.Count > 0 Then
With rng
.Text = vbCrLf & "Bookmark" & vbTab & "Page" & vbTab & "Line" & vbTab & "Story Range" & vbTab & "Contents"
For Each oBkMrk In ActiveDocument.Bookmarks
.InsertAfter vbCrLf & oBkMrk.Name & vbTab
.InsertAfter oBkMrk.Range.Characters.First.Information(wdActiveEndAdjustedPageNumber)
.InsertAfter vbTab & oBkMrk.Range.Information(wdFirstCharacterLineNumber)
Select Case oBkMrk.StoryType
Case 1: StrStory = "Main text"
Case 2: StrStory = "Footnotes"
Case 3: StrStory = "Endnotes"
Case 4: StrStory = "Comments"
Case 5: StrStory = "Text frame"
Case 6: StrStory = "Even pages header"
Case 7: StrStory = "Primary header"
Case 8: StrStory = "Even pages footer"
Case 9: StrStory = "Primary footer"
Case 10: StrStory = "First page header"
Case 11: StrStory = "First page footer"
Case 12: StrStory = "Footnote separator"
Case 13: StrStory = "Footnote continuation separator"
Case 14: StrStory = "Footnote continuation notice"
Case 15: StrStory = "Endnote separator"
Case 16: StrStory = "Endnote continuation separator"
Case 17: StrStory = "Endnote continuation notice"
Case Else: StrStory = "Unknown"
End Select
.InsertAfter vbTab & StrStory & vbTab & oBkMrk.Range.Text
Next oBkMrk
.Start = .Start + 1
.ConvertToTable Separator:=vbTab
.Tables(1).Rows.First.Range.Font.Bold = True
'.Copy
End With
End If
End With
Set rng = Nothing
Application.ScreenUpdating = True
End Sub
I just want a code to make this code copy all references from this document with the same name and same page number, and the same number of lines in another document
2016-03-20 13:10:16
Jim Walton
If you need the list in location order rather than alphabetical order, here is a quick fix:
Change:
Selection.TypeText Text:=ActiveDocument.Bookmarks(J).Name
To:
Selection.TypeText Text:=ActiveDocument.Range.Bookmarks(J).Name
This works for Word 2016.
Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments