Sub test()
Const doc As String = "E:\Téléchargement Chrome\Fonction XLOOKUP.docx"
Dim rep, lig As Long
rep = statsDoc(doc)
If IsError(rep) Then
MsgBox "Fichier non trouvé"
Else
lig = Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(lig, 1) = Now
Cells(lig, 2).Resize(, 6) = rep
End If
End Sub
Function statsDoc(d As String, Optional IncludeFootnotesAndEndnotes As Boolean = False)
Dim wdDoc As Object, stats(1 To 1, 0 To 5) As Long, i As Long
If Dir(d) = "" Then
statsDoc = CVErr(xlErrValue)
Else
Set wdDoc = GetObject(d)
For i = 0 To 5
stats(1, i) = wdDoc.ComputeStatistics(i, IncludeFootnotesAndEndnotes)
Next i
Set wdDoc = Nothing
statsDoc = stats
End If
End Function