Columns。 Add 方法(Word)Columns.Add method (Word)

返回一个 Column 对象,该对象代表添加到表中的列。Returns a Column object that represents a column added to a table.

语法Syntax

表达式AddBeforeColumnexpression.Add (BeforeColumn)

expression 是必需的。expression Required. 一个代表 "Columns" 集合的变量。A variable that represents a 'Columns' collection.

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
BeforeColumnBeforeColumn 可选Optional VariantVariant 代表将会直接显示在新列右侧的 Column 对象。A Column object that represents the column that will appear immediately to the right of the new column.

返回值Return value

ColumnColumn

示例Example

本示例在活动文档中创建一个有两行两列的表格,然后在第一列之前添加一列。This example creates a table with two columns and two rows in the active document and then adds another column before the first column. 新列的宽度设为 1.5 英寸。The width of the new column is set at 1.5 inches.

Sub AddATable() 
 Dim myTable As Table 
 Dim newCol As Column 
 
 Set myTable = ActiveDocument.Tables.Add(Selection.Range, 2, 2) 
 Set newCol = myTable.Columns.Add(BeforeColumn:=myTable.Columns(1)) 
 newCol.SetWidth ColumnWidth:=InchesToPoints(1.5), _ 
 RulerStyle:=wdAdjustNone 
End Sub

另请参阅See also

列集合对象Columns Collection Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.