I would like to detect and skip merged cells in vba on word 2010.
I'm making a macro which need to write in the first column but I've some merged cells and I don't want to write in. All examples I found was for Excel.
I tried to detect the number of columns per rows but that didn't works. I got "Error 5991 table has vertically merged cells"
.
So how can I just skip the row when I get merged cells ?
Sub test()
Dim Ro As Integer, Col As Integer
'init
Count = 1
Col = 1
For Ro = 4 To ActiveDocument.Tables(4).Rows.Count
'format
If Count < 10 Then
flag = "0"
Else
flag = ""
End If
'detect merge
If ActiveDocument.Tables(4).Rows(Ro).Cells.Count = 9 Then
ActiveDocument.Tables(4).Cell(Ro, Col).Range.Text = "R" & flag & CStr(Count)
Count = Count + 1
Else
Ro = Ro + 1
End If
Next Ro
End Sub