Word VBA: Selecting the First Column in a Selected Table

This Word VBA macro selects the first column in a selected table.

Macro Example

Sub SelectFirstColumn()

  Selection.Tables(1).Columns(1).Select

End Sub

Description

[Application.]Selection

  Selection...

The [Application.]Selection property returns the Selection object that represents a selected range on a Word document.

obj-Word-Application-Selection

Because the Selection property is a member of the Word.Global class, we can omit the Application property.

obj-Word-Global-Selection

Selection.Tables

  Selection.Tables...

The Selection.Tables property returns the Tables collection object in a selected range.

obj-Word-Selection-Tables

Tables(1) (Tables.Item(1))

  Selection.Tables(1)...

The Tables.Item method returns an individual Table object in the Tables collection object. And the Tables.Item(1) represents the first table.

obj-Word-Tables-Item

The Item method is a default member of the Tables collection object. We can see a little blue marble beside its icon in the Object Browser.
So we can omit the .Item.

Tables(1).Columns (Table.Columns)

  Selection.Tables(1).Columns...

The Tables(1).Columns (Table.Columns property) returns a Columns collection object that represents all the table columns within a table.

obj-Word-Table-Columns

Columns(1) (Columns.Item(1))

The Columns.Item method returns an individual Column object in the Columns collection object. And the Columns.Item(1) represents the first column.

obj-Word-Columns-Item

The Item method is a default member of the Columns collection object. We can see a little blue marble beside its icon in the Object Browser.
So we can omit the .Item.

Columns(1).Select (Column.Select)

  Selection.Tables(1).Columns(1).Select

The Columns(1).Select (Column.Select method) selects the column.

obj-Word-Column-Select

Sub SelectFirstColumn()

  Selection.Tables(1).Columns(1).Select

End Sub

Properties

http://www.relief.jp/itnote/archives/word-vba-selecting-a-column.php

Apply To

  • Word 2013
  • Word 2010
  • Word 2007