문제

In MS Word 2010, changing the width of a merged cell is a bit tricksy.

Imagine a simple 2 x 2 table. The cells of the top row are merged, the cells of the second row are not.

If the cursor in placed in Cell(2, 1) (Using Word indices) and the width is changed, then the width of the top row will be changed to match that of the "Active" cell.

If, however, the selection is extended to include the "End of Row" hidden character, then change only affects the selected cell, as intended.

Does anyone know how to replicate this behaviour in VBA?

Cheers

Dan

도움이 되었습니까?

해결책

Turns out that if you User Cell.Select then the behaviour is as I wanted

With Selection.Table(1)
    .Cell(1, 1).Select
    .Selection.Cells.Width = MillimetersToPoints(150)
    .Cell(2, 1).Select
    .Selection.Cells.Width = MillimetersToPoints(150)
    .Cell(3, 1).Select
    .Selection.Cells.Width = MillimetersToPoints(50)
    .Cell(3, 2).Select
    .Selection.Cells.Width = MillimetersToPoints(100)
End With
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top