Option Explicit
Sub ExtractData()
Dim TableEnCours As Integer, NumeroTable As Integer, PageEnCours As Integer, Ir As Integer, C As Integer
Dim WdApp As New Word.Application, WdDoc As Word.Document, WdTables As Word.Tables, WdTable As Word.Table
Dim Sh As Worksheet
Set Sh = ActiveSheet
With Sh
Ir = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
End With
With WdApp
.Visible = True
Set WdDoc = .Documents.Open(ActiveWorkbook.Path & "\family-survey-form1.docx")
End With
With WdDoc
Set WdTables = .Tables
PageEnCours = 1
For TableEnCours = 1 To WdTables.Count
Set WdTable = WdTables(TableEnCours)
If WdTable.Cell(1, 1).Range.Information(wdActiveEndPageNumber) > PageEnCours Then
PageEnCours = WdTable.Cell(1, 1).Range.Information(wdActiveEndPageNumber)
NumeroTable = 0
Ir = Ir + 1
End If
NumeroTable = NumeroTable + 1
Select Case NumeroTable
Case 2
For C = 1 To 5
Sh.Cells(Ir, C).Value = Application.WorksheetFunction.Clean(WdTable.Cell(C, 2).Range.Text)
Next
Case 3
For C = 1 To 5
Sh.Cells(Ir, 5 + C).Value = Application.WorksheetFunction.Clean(WdTable.Cell(C, 2).Range.Text)
Next
Case 4
For C = 1 To 13
Sh.Cells(Ir, 10 + C).Value = Application.WorksheetFunction.Clean(WdTable.Cell(C, 2).Range.Text)
Next
Sh.Cells(Ir, 24).Value = Application.WorksheetFunction.Clean(WdTable.Cell(2, 3).Range.Text)
End Select
Set WdTable = Nothing
Next TableEnCours
.Close False
End With
WdApp.Quit
MsgBox "Fin de l'import !", vbInformation
Set WdTables = Nothing: Set WdDoc = Nothing
End Sub