For what you've described, the following should suffice:
Sub GetData()
Application.ScreenUpdating = False
Dim StrFolder As String, StrFile As String, StrFnd As String
Dim wdApp As Object, wdDoc As Object, bStrt As Boolean
Dim WkSht As Worksheet, LRow As Long, i As Long, j As Long
StrFolder = GetFolder
If StrFolder = "" Then Exit Sub
Set WkSht = ThisWorkbook.Sheets("Sheet1")
LRow = WkSht.Range("A" & WkSht.UsedRange.Rows.Count).End(xlUp).Row
' Test whether Word is already running.
On Error Resume Next
bStrt = False ' Flag to record if we start Word, so we can close it later.
Set wdApp = GetObject(, "Word.Application")
'Start Excel if it isn't running
If wdApp Is Nothing Then
Set wdApp = CreateObject("Word.Application")
If wdApp Is Nothing Then
MsgBox "Can't start Word.", vbExclamation
Exit Sub
End If
' Record that we've started Word.
bStrt = True
End If
On Error GoTo 0
StrFile = Dir(StrFolder & "\*.doc")
While StrFile <> ""
LRow = LRow + 1
Set wdDoc = wdApp.Documents.Open(Filename:=StrFolder & "\" & StrFile, AddToRecentFiles:=False, Visible:=False, ReadOnly:=True)
With wdDoc
'Get the data for each table
With .Tables(1)
For i = 1 To 3
WkSht.Cells(LRow, i).Value = Split(.Cell(2, i).Range.Text, vbCr)(0)
Next
End With
With .Tables(2)
For i = 1 To 4
WkSht.Cells(LRow, i + 3).Value = Split(.Cell(2, i).Range.Text, vbCr)(0)
Next
End With
With .Tables(3)
For i = 1 To 3
WkSht.Cells(LRow, i + 7).Value = Split(.Cell(2, i).Range.Text, vbCr)(0)
WkSht.Cells(LRow, i + 10).Value = Split(.Cell(3, i).Range.Text, vbCr)(0)
WkSht.Cells(LRow, i + 13).Value = Split(.Cell(4, i).Range.Text, vbCr)(0)
Next
End With
'Close without saving changes
.Close SaveChanges:=False
End With
StrFile = Dir()
Wend
If bStrt = True Then wdApp.Quit
Set wdDoc = Nothing: Set wdApp = Nothing: Set WkSht = 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
The macro includes a folder browser, so all you need do is select the folder concerned.
Note: The macro will fail if the folder contains a document not containing the three tables you described as the first three tables in it.
Bookmarks