2011-11-29 187 views
0

在MS Word 2010中,更改合併單元格的寬度有點困難。更改VBA中合併表格單元格的寬度(Word 2010)

想象一個簡單的2 x 2表格。頂行的單元格合併,第二行的單元格不合並。

如果放置在Cell(2,1)(使用Word索引)中的遊標和寬度發生了變化,則頂行的寬度將更改爲與「活動」單元格的寬度相匹配。

但是,如果選擇擴展到包括「行尾」隱藏字符,則更改僅影響所選的單元格。

有誰知道如何在VBA中複製這種行爲?

乾杯

回答

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