Share via


Columns Property [Publisher 2003 VBA Language Reference]

Columns property as it applies to the LayoutGuides and TextFrame objects.

Returns or sets a Long that represents the number of guide columns on a page or the number of columns in a text frame. Read/write.

expression.Columns

expression Required. An expression that returns one of the above objects.

Columns property as it applies to the Table object.

Returns a Columns collection that represents all the columns of the specified table.

expression.Columns

expression Required. An expression that returns one of the above objects.

Example

As it applies to the LayoutGuide objects.

This example adds a new page with a text box and formats the active publication with two guide columns and the new text box with two newspaper-type columns.

Sub LayoutTwoColumnPage()
    Dim shpTextBox As Shape
    With ActiveDocument
        .Pages.Add Count:=1, After:=1
        Set shpTextBox = .Pages(2).Shapes.AddTextbox _
            (Orientation:=pbTextOrientationHorizontal, _
            Left:=72, Top:=72, Width:=468, Height:=318)
        With .LayoutGuides
            .Columns = 2
            .Rows = 2
        End With
        With shpTextBox.TextFrame
            .Columns = 2
        End With
    End With
End Sub

As it applies to the Table object.

This example enters a bold number into each cell in the specified table. This example assumes the specified shape is a table and not another type of shape.

Sub CountCellsByColumn()
    Dim shpTable As Shape
    Dim colTable As Column
    Dim celTable As Cell
    Dim intCount As Integer

    intCount = 1

    Set shpTable = ActiveDocument.Pages(2).Shapes(1)

    'Loops through each column in the table
    For Each colTable In shpTable.Table.Columns

        'Loops through each cell in the column
        For Each celTable In colTable.Cells
            With celTable.Text
                .Text = intCount
                .ParagraphFormat.Alignment = _
                    pbParagraphAlignmentCenter
                .Font.Bold = msoTrue
                intCount = intCount + 1
            End With
        Next celTable
    Next colTable

End Sub

Applies to | LayoutGuides Object | Table Object | TextFrame Object