View Single Post
 
Old 06-27-2012, 04:02 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,382
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You could use code like:
Code:
Sub GetBookmarks()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document
Dim ArrBkMks As String, i As Long, StrBkMk As String, StrOut As String
ArrBkMks = "Bookmark1,Bookmark2,Bookmark3"
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
  Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
  With wdDoc
    StrOut = StrOut & .Name
    For i = 0 To UBound(Split(ArrBkMks, ","))
      StrBkMk = Split(ArrBkMks, ",")(i)
      StrOut = StrOut & vbTab & StrBkMk & ": "
      If .Bookmarks.Exists(StrBkMk) Then
        StrOut = StrOut & .Bookmarks(StrBkMk).Range.Text
      End If
    Next i
  End With
  StrOut = StrOut & vbCr
  wdDoc.Close SaveChanges:=False
  strFile = Dir()
Wend
Set wdDoc = Nothing
ActiveDocument.Range.InsertAfter StrOut
Application.ScreenUpdating = True
End Sub
 
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
Simply replace the bookmark names in the 'ArrBkMks' variable with your own bookmark names, then run the macro. Point its browser to the target folder and let it run.

You'll get a list of the documents, the bookmarks and their contents exported to the active document.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote