Word) (TableStyle 对象

代表可应用于表格的单个样式。

备注

使用 表格 属性的 样式 返回一个 TableStyle 对象的对象。 使用 边框 要将边框应用于整个表格的属性。 使用 条件 要仅对指定表中的部分应用边框或底纹的方法。 本示例创建一个新的表样式并设置目录的格式具有四周边框。 特殊的边框和底纹应用于第一个和最后一个行和最后一列。

Sub NewTableStyle() 
 Dim styTable As Style 
 
 Set styTable = ActiveDocument.Styles.Add( _ 
 Name:="TableStyle 1", Type:=wdStyleTypeTable) 
 
 With styTable.Table 
 
 'Apply borders around table 
 .Borders(wdBorderTop).LineStyle = wdLineStyleSingle 
 .Borders(wdBorderBottom).LineStyle = wdLineStyleSingle 
 .Borders(wdBorderLeft).LineStyle = wdLineStyleSingle 
 .Borders(wdBorderRight).LineStyle = wdLineStyleSingle 
 
 'Apply a double border to the heading row 
 .Condition(wdFirstRow).Borders(wdBorderBottom) _ 
 .LineStyle = wdLineStyleDouble 
 
 'Apply a double border to the last column 
 .Condition(wdLastColumn).Borders(wdBorderLeft) _ 
 .LineStyle = wdLineStyleDouble 
 
 'Apply shading to last row 
 .Condition(wdLastRow).Shading _ 
 .BackgroundPatternColor = wdColorGray125 
 
 End With 
 
End Sub

方法

名称
Condition

属性

名称
Alignment
AllowBreakAcrossPage
AllowPageBreaks
应用程序
Borders
BottomPadding
ColumnStripe
Creator
LeftIndent
LeftPadding
Parent
RightPadding
RowStripe
Shading
Spacing
TableDirection
TopPadding

另请参阅

Word 对象模型参考

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。