Column Object

Multiple objects
Column
Multiple objects

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 index 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).

The following example selects column one in table one in the active document.

ActiveDocument.Tables(1).Columns(1).Select

Use the Column property with a Cell object to return a Column object. The following example deletes the text in cell one, inserts new text, and then sorts the entire column.

With ActiveDocument.Tables(1).Cell(1, 1)
    .Range.Delete
    .Range.InsertBefore "Sales"
    .Column.Sort
End With

Use the Add method to add a column to a table. The following example adds a column to the first table in the active document, and then it makes the column widths equal.

If ActiveDocument.Tables.Count >= 1 Then
    Set myTable = ActiveDocument.Tables(1)
    myTable.Columns.Add BeforeColumn:=myTable.Columns(1)
    myTable.Columns.DistributeWidth
End If

Remarks

Use the Information property with a Selection object to return the current column number. The following example selects the current column and then displays the column number in a message box.

If Selection.Information(wdWithInTable) = True Then
    Selection.Columns(1).Select
    MsgBox "Column " _
        & Selection.Information(wdStartOfRangeColumnNumber)
End If

Properties | Application Property | Borders Property | Cells Property | Creator Property | Index Property | IsFirst Property | IsLast Property | NestingLevel Property | Next Property | Parent Property | PreferredWidth Property | PreferredWidthType Property | Previous Property | Shading Property | Width Property

Methods | AutoFit Method | Delete Method | Select Method | SetWidth Method | Sort Method

Parent Objects | Cell Object | Column Object | Columns Collection

Child Objects | Borders Object | Cells Object | Column Object | Shading Object

See Also | Cell Object | Error Accessing a Table Row or Column | Row Object