我正在使用此代码在word文档中创建表:
'create the table
oDoc_detail_table = oDoc_detail.Tables.Add(oDoc_detail.Bookmarks.Item("\endofdoc").Range, 1, 6)
'align the table in the center
oDoc_detail_table.Rows.Alignment = word.WdRowAlignment.wdAlignRowCenter
'set styles
oDoc_detail_table.Range.Font.Name = "Calibri"
oDoc_detail_table.Range.Font.Size = 8
'set width for columns
oDoc_detail_table.Cell(1, 1).Width = 80
oDoc_detail_table.Cell(1, 2).Width = 30
oDoc_detail_table.Cell(1, 3).Width = 330
oDoc_detail_table.Cell(1, 4).Width = 60
oDoc_detail_table.Cell(1, 5).Width = 60
oDoc_detail_table.Cell(1, 6).Width = 40
我希望能够设置表中所有行的高度(我在代码中动态添加行)
另外,我希望垂直对齐位于中心。
我怎么能在代码中执行此操作?
答案 0 :(得分:1)
Have you tried setting the height property when you are adding the new rows? Is there a reason you need to set the height of all rows after they have been added?
If so, have you tried looping to set? This should execute quickly, applying all after the loop executes, eg:
For each r as Row in oDoc_detail_table.Rows
r.Height = 100
Next r