Hi Paul,
This worked except for the first new row did not size with the table.
I found a thread where you suggested to remove the table and place in Excel, unmerge the cells there and then put back into Word.
This might work well for my needs as I don't think table with vertically merged cells will be a large number.
So, my thought, do as I mentioned above, but run my original code but add a skip when vertically merged cells are identified. As those tables are identified, I can write down the table number and deal with them one by one.
I found this, but is this the best to skip? I only need to display and then skip if vertical merged cells are identified, but I don't need the message that gives the error description.
Code:
Sub tableformat()
Dim i As Long
Dim oRow As Row
Dim oCol As Column
On Error GoTo ErrHandler
For i = 1 To Selection.Tables.Count
For Each oRow In Selection.Tables(i).Rows
Next oRow
NextStep:
For Each oCol In Selection.Tables(i).Columns
Next oCol
NextTable:
Next i
Exit Sub
ErrHandler:
Select Case Err
Case 5991
MsgBox "Table #" & i & " has vertically merged cells"
Resume NextStep
Case Else
MsgBox "Error " & Err.Number & ": " & _
Err.Description & " in table #" & i
Resume NextTable
End Select
End Sub
Note: On further looking, I see the two errors are for checking for merged rows and then checking merged columns. In my case, the original error in post #1 was due to the vertically merged and not the horizontal. So far in all the tables I've been cleaning up have multiple column merged and never an error adding the top row.