Sub ImportWordTables()
Dim wdDoc As Object
Dim wdFileName As Variant
Dim TableNo, iTable As Integer
Dim iRow, iCol As Long
Dim iEis, iWens, iLog As Long
wdFileName = Application.GetOpenFilename("Word files (*.doc*),*.doc*", , _
"Browse for file containing table to be imported")
If wdFileName = False Then Exit Sub
Set wdDoc = GetObject(wdFileName)
iEis = 1
iWens = 1
iLog = 1
With wdDoc
TableNo = wdDoc.tables.Count
If TableNo = 0 Then
MsgBox "This document contains no tables", _
vbExclamation, "Import Word Table"
End If
For iTable = 1 To TableNo
With .tables(iTable)
If Left(.cell(1, 1).Range.ListFormat.ListString, 1) = "E" Then
iEis = iEis + 1
ActiveWorkbook.Worksheets("Eisen").Activate
Cells(iEis, "A") = iTable
Cells(iEis, "B") = WorksheetFunction.Clean(.cell(1, 1).Range.ListFormat.ListString)
Cells(iEis, "C") = WorksheetFunction.Clean(.cell(1, 2).Range.Text)
ElseIf Left(.cell(1, 1).Range.ListFormat.ListString, 1) = "W" Then
iWens = iWens + 1
ActiveWorkbook.Worksheets("Wensen").Activate
Cells(iWens, "A") = iTable
Cells(iWens, "B") = WorksheetFunction.Clean(.cell(1, 1).Range.ListFormat.ListString)
Cells(iWens, "C") = WorksheetFunction.Clean(.cell(1, 2).Range.Text)
Else
iLog = iLog + 1
ActiveWorkbook.Worksheets("Log").Activate
Cells(iLog, "A") = iTable
Cells(iLog, "B") = WorksheetFunction.Clean(.cell(1, 1).Range.ListFormat.ListString)
Cells(iLog, "C") = WorksheetFunction.Clean(.cell(1, 2).Range.Text)
End If
End With
Next iTable
End With
Set wdDoc = Nothing
End Sub