在MS Word 2010中,更改合并单元格的宽度有点棘手。
想象一个简单的2 x 2表。顶行的单元格合并,第二行的单元格不合并。
如果光标位于单元格(2,1)(使用Word索引)并且宽度发生变化,则顶行的宽度将更改为与“活动”单元格的宽度相匹配。
但是,如果选择范围扩大到包含“行结束”隐藏字符,则更改只会影响所选单元格。
有人知道如何在VBA中复制此行为吗?
干杯
丹
答案 0 :(得分:0)
原来,如果你用户Cell.Select然后行为是我想要的
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