Prev Previous Post   Next Post Next
  #5   Report Post  
ERS ERS is offline
Junior Member
 
Posts: 0
Default

Quote:
Originally Posted by CMK View Post
I have created 30 or so documents with at least 75 bookmarks in each. Is
there any way I can export a bookmark list (TXT) from each document? I need
to compare bookmarks between documents and I'm hoping that I don't have to
type them all out.
Hi CMK,
The following macro shall enable you to extract bookmarks within a document to a new one.

Create a new module and paste these codes:

Sub ExtractBookmarksInMultiDoc()
Dim objBookmark As Bookmark
Dim objTable As Table
Dim nRow As Integer
Dim objDoc As Document, objNewDoc As Document
Dim objParagraph As Paragraph
Dim strFolder As String, strFile As String

strFolder = InputBox("Enter folder path he ")
strFile = Dir(strFolder & "*.docx", vbNormal)

While strFile ""
Set objDoc = Documents.Open(FileName:=strFolder & strFile)
Set objDoc = ActiveDocument
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
objNewDoc.SaveAs2 FileName:=objDoc.Path & "\" & "Bookmarks in " & objDoc.Name
objDoc.Close
strFile = Dir()
Wend
End Sub


This macro is for batch processing.

Bookmarks will be arranged in a table in new document with bookmark texts and page numbers in link.

You can follow the link to quickly jump to the bookmark location in main document.

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

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

Hope that helps!
ERS

Last edited by ERS : April 25th 17 at 04:45 AM


 
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
View (displaying) bookmarks - Word 2003 Eric G Microsoft Word Help 4 May 18th 05 04:44 AM
Find & Replace Bookmarks jbc Microsoft Word Help 1 December 24th 04 09:03 PM
Add bookmarks in header/footer Kind writer/user/programmer Microsoft Word Help 1 December 7th 04 07:55 PM
Lock portion of the document after inserting bookmarks Sesame Microsoft Word Help 2 December 7th 04 03:49 AM
How to protect bookmarks Flip Microsoft Word Help 6 November 30th 04 12:38 PM


All times are GMT +1. The time now is 06:52 PM.

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

About Us

"It's about Microsoft Word"