title: VBA code to read tables from Word document
body: <p>Need help to modify this VBA code to read multiple tables from a Word document. It only reads one table, but I would like to import more than one into the same Excel sheet.</p>
  
  <pre><code>Sub ImportWordTables()
     'Imports a table from Word document 
  
     Dim wdDoc         As Object
     Dim wdFileName    As Variant
     Dim TableNo       As Integer  'number of tables in Word doc
     Dim iTable        As Integer  'table number index
     Dim iRow          As Long     'row index in Excel
     Dim iCol          As Integer  'column index in Excel
  
     wdFileName = Application.GetOpenFilename("Word files (*.doc*),*.doc*", , _
       "Browse for file containing table to be imported")
  
     If wdFileName = False Then Exit Sub '(user cancelled import file browser)
  
     Set wdDoc = GetObject(wdFileName)   'open Word file
  
     With wdDoc
        TableNo = wdDoc.tables.Count
        If TableNo = 0 Then
           MsgBox "This document contains no tables", _
           vbExclamation, "Import Word Table"
        ElseIf TableNo &gt; 1 Then
           TableNo = InputBox("This Word document contains " &amp; TableNo &amp; " tables." &amp; vbCrLf &amp; _
           "Enter table number of table to import", "Import Word Table", "1")
        End If
        With .tables(TableNo)
           'copy cell contents from Word table cells to Excel cells
           For iRow = 1 To .Rows.Count
              For iCol = 1 To .Columns.Count
                 Cells(iRow, iCol) = WorksheetFunction.Clean(.cell(iRow, iCol).Range.Text)
              Next iCol
           Next iRow
        End With
     End With
     Set wdDoc = Nothing       
  End Sub
  </code></pre>