Column object (Word)
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.
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
Name |
---|
Application |
Borders |
Cells |
Creator |
Index |
IsFirst |
IsLast |
NestingLevel |
Next |
Parent |
PreferredWidth |
PreferredWidthType |
Previous |
Shading |
Width |
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.