Hello Pros,
I've been trying all day to figure out how to select from all tables the range as of rows(1) and Column(2), till the end of the table, on all tables.
I found a script where I've modified it with my needs
How to select a range of the second row to the last row Word VBA - Stack Overflow
Where I've coded this script which works well for 1 table:
Code:
Dim aTbl As Table
Set aTbl = ActiveDocument.Tables(1)
Dim NewTable As Boolean
'if not new Table Select All but first row, Else Select whole table
If NewTable = 0 Then
With aTbl
ActiveDocument.Range(.Cell(1, 2).Range.Start, .Rows(.Rows.Count).Range.End).Select
End With
Else
aTbl.Select
End If
On Error GoTo 0
******************************
However, when applied too all table, I've modified it to this script:
Code:
Dim xTbl As Table
For Each xTbl In ActiveDocument.Tables
Dim NewTable As Boolean
'if not new Table Select All but first column, Else Select whole table
If NewTable = 0 Then
With xTbl
ActiveDocument.Range(.Cell(1, 2).Range.Start, .Rows(.Rows.Count).Range.End).Select
End With
Else
xTbl.Select
End If
Next xTbl
On Error GoTo 0
When using this code, it selects the very last table of the document.
To test potential scripts, I've used 5 columns and 5 rows, x5 tables.
Any idea how to fix this issue?
I would be sooooooooo greatful for any insights to help me with my script.
Cendrinne