View Single Post
 
Old 01-15-2019, 04:45 PM
jeffreybrown jeffreybrown is offline Windows Vista Office 2007
Expert
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default Format tables with vertically merged cells

I'm fixing some word products which already have some tables with vertically merged cells.

The macro works fine, but when encountering the tables with the vertically merged cells, getting the error.

Quote:
Cannot access individual rows in this collection because the table has vertically merged cells.
Is this possible to overcome without unmerge those vertically merged cells?

Code:
Sub FormatFirstTableRow()
    Dim Tbl As Table
    Dim i As Long
    Dim iRow As Row
    Application.ScreenUpdating = False
    For Each Tbl In ActiveDocument.Tables
        With Tbl
            .Rows(1).Select
            If InStr(1, Selection.Text, "Table") = 1 Or InStr(1, Selection.Text, "Figure") = 1 Then
                With .Rows(1)
                    .Range.Style = "TblHeader"
                    .Borders.Enable = False
                    .Borders(wdBorderBottom).LineStyle = Options.DefaultBorderLineStyle
                    .Range.Cells.VerticalAlignment = wdCellAlignVerticalCenter
                End With
                .AutoFitBehavior (wdAutoFitContent)
                .Rows.HeightRule = wdRowHeightExactly
                .Rows.Height = InchesToPoints(0.2)
            End If
        End With
    Next
    ActiveDocument.Fields.Update
    Application.ScreenUpdating = True
End Sub
Reply With Quote