Share via


Column Object [Publisher 2003 VBA Language Reference]

Columns
column
CellRange

Represents a single table column. The Column object is a member of the Columns collection. The Columns collection includes all the columns in a table, selection, or range.

Using the Column object

Use Columns(index), where index is the column number, to return a single Column object. The index number represents the position of the column in the Columns collection (counting from left to right). This example selects column three in the first shape in the active publication. This example assumes the first shape is a table and not another type of shape.

Sub SelectColumn()
    ActiveDocument.Pages(2).Shapes(1).Table.Columns(3).Cells.Select
End Sub

Use the Item method of a Columns collection to return a Column object. This example enters text into the first cell of the third column of the specified table and formats the text with a bold, 15-point font. This example assumes the first shape is a table and not another type of shape.

Sub ColumnHeading()
    With ActiveDocument.Pages(2).Shapes(1).Table.Columns(3) _
            .Cells(1).Text
        .Text = "Sales"
        .Font.Bold = msoTrue
        .Font.Size = 15
    End With
End Sub

Use the Delete method to delete a column from a table. This example deletes the column added in the above example.

Sub DeleteColumn()
    ActiveDocument.Pages(2).Shapes(1).Table.Columns(3).Delete
End Sub

Properties | Application Property | Cells Property | Parent Property | Width Property

Methods | Delete Method

Parent Objects

Child Objects | CellRange Object