A family of Microsoft word processing software products for creating web, email, and print documents.
The following code will extract all tables from the documents in the selected folder, plus the paragraph before & after (Word doesn't really work with lines):
Sub GetTableData()
Application.ScreenUpdating = False
Dim DocTgt As Document, DocSrc As Document, Tbl As Table, Rng As Range
Dim strFolder As String, strFile As String
strFolder = GetFolder: If strFolder = "" Then GoTo ErrExit
Set DocTgt = ActiveDocument
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
Set DocSrc = Documents.Open(FileName:=strFolder & "" & strFile, AddToRecentFiles:=False, Visible:=False)
With DocSrc
For Each Tbl In .Tables
Set Rng = Tbl.Range
Rng.MoveStart wdParagraph, -1
Rng.MoveEnd wdParagraph, 1
With DocTgt.Range
.Characters.Last.FormattedText = Rng.FormattedText
End With
Next
.Close SaveChanges:=False
End With
strFile = Dir()
Wend
ErrExit:
Set DocTgt = Nothing: Set DocSrc = Nothing
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