VBA Word table to Excel Paragraph and For Error

Vankootens

New member
Joined
Jan 11, 2016
Messages
3
Reaction score
0
Points
0
Excel Version(s)
Office 365
I have two problems:

I need to copy a table in .docx that has paragraph numbering in column A. The first row the of the table is a always merged(A-C). The table can be any number of rows but follows the same format.
.docx table Ex:

A B C
|'title...'|
|1.| T | F |
|2.| F | T |
|3.| T | T |

I know this code looks at (2, 1) but it does not return that table numbering '1.'. It just returns (2, 1) as a blank cell. Ideally it would return the values of '1' (Without the period).

When I run the full code it passes through to 'Next iCol' the first time and then errors at 'Cells(resultRow, iCol)...' with: "The Requested member of the collection does not exist". I am thinking it has something to do with the first row being merged so Cell(1,2) does not exist but I am not sure of the solution.

CODE IN QUESTION:

ElseIf .Found = True Then
For iRow = 1 To wrdDoc.Tables(3).Rows.Count
For iCol = 1 To wrdDoc.Tables(3).Columns.Count
Cells(resultRow, iCol) = WorksheetFunction.Clean(wrdDoc.Tables(3).Cell(iRow, iCol).Range.Text)
Next iCol
resultRow = resultRow + 1
Next iRow
resultRow = resultRow + 1
End If

The final results in excel should match the .docx table without the column A period. If is easier the 'title' can just be placed in A1 with the rest of the table to follow.

A B C
|'title..'|
|1| T | F |
|2| F | T |
|3| T | T |

OR

A B C
|tle| | |
|1 | T | F |
|2 | F | T |
|3 | T | T |
Thank you for your help and time.
 

Vankootens

New member
Joined
Jan 11, 2016
Messages
3
Reaction score
0
Points
0
Excel Version(s)
Office 365
Okay solution for problem 2:

For x = 1 To wrdDoc.Tables(3).Range.Cells.Count
If wrdDoc.Tables(3).Range.Cells(x).RowIndex > iRow Then resultRow = resultRow + 1
iRow = wrdDoc.Tables(3).Range.Cells(x).RowIndex: iCol = wrdDoc.Tables(3).Range.Cells(x).ColumnIndex
Cells(resultRow, iCol) = WorksheetFunction.Clean(wrdDoc.Tables(3).Range.Cells(x).Range.Text)
Next
End If

Still having problems with pulling in the paragraph numbering in column A.
 
Top