Hi all,
I have some background with Excel VBA, but am new to applying VBA to Word, so am looking for help.
My goal is to retrieve a particular table from a bunch of .docx documents and paste them into Excel. I have a working code for most of the process, and have been automating the script to retrieve the 7th table of each word file. However, I found out that the docs actually have different number of tables, and it's not always the 7th table that's the one I want. Fortunately, the table I want is always immediately preceded by the title "III. TableINeed". Does anyone know how I can locate which table number this is based on its title?
To give you an idea of the code, here's a relevant portion:
With wDoc
With .Tables(7)
For wRow = 2 To 13
For wCol = 2 To 3
Cells(wRow, wCol) = WorksheetFunction.Clean(.Cell(wRow, wCol).Range.Text)
Next wCol
Next wRow
End With
End With
As you can see I now hard code to table 7, but that needs to be dynamic based on the word file.
Thanks!
Bookmarks