Home |
Search |
Today's Posts |
#5
|
|||
|
|||
Quote:
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
View (displaying) bookmarks - Word 2003 | Microsoft Word Help | |||
Find & Replace Bookmarks | Microsoft Word Help | |||
Add bookmarks in header/footer | Microsoft Word Help | |||
Lock portion of the document after inserting bookmarks | Microsoft Word Help | |||
How to protect bookmarks | Microsoft Word Help |