cols Property

Microsoft FrontPage Visual Basic

Returns or sets a Long that represents the number of columns in a table or the width of a TEXTAREA element, which corresponds to the value of the cols attribute.

expression.cols

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

Remarks

When applied to an FPHTMLTable or IHTMLTable object, the cols property specifies the number of columns in the table. When applied to an FPHTMLTextAreaElement or IHTMLTextAreaElement object, the cols property specifies the width of the TEXTAREA element.

Showcols property as it applies to the FPHTMLFrameSetSite and IHTMLFrameSetElement objects.

Sets or returns a String that represents the number and width of vertical frames in a FRAMESET element, which corresponds to the value of the cols attribute.

expression.cols

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

Remarks

The String value for the cols property can be one or more of the following comma-delimited values:

width Integer that specifies the frame width, in pixels.
percentage Integer, followed by a %. The value is a percentage of total available width.
* Integer that specifies the frame width as a relative value. After allocating pixel or percentage values, the remaining space is divided among all relative-sized frames.

The number of comma-separated items is equal to the number of vertical frames contained within the FRAMESET, while the value of each item determines the frame width.

Example

ShowAs it applies to the FPHTMLTable object.

The following example sets the number of columns, background color, height, and width of the specified table.

Sub SetTableColumns(objTable As FPHTMLTable, strCols As String, _
        strColor As String, strHeight As String, strWidth As String)
    With objTable
        .cols = strCols
        .bgColor = strColor
        .Height = strHeight
        .Width = strWidth
    End With
End Sub

Use the following example to call the preceding subroutine.

Sub CallSetTableColumns()
    Dim objTable As FPHTMLTable
    
    Set objTable = ActiveDocument.all.tags("table").Item(0)
    
    Call SetTableColumns(objTable, "3", "#883399", "200", "75%")
End Sub

ShowAs it applies to the FPHTMLFrameSetSite object.

The following example replaces the active document's current HTML with a frameset, and then specifies the number of rows or columns contained in each frameset.

Sub CreateFrameSet()
    Dim objFrames As FPHTMLFrameSetSite

    ActiveDocument.body.innerHTML = "<frameset id=""topframe"">" & vbCrLf & _
        vbTab & "<frame id=""top"">" & vbCrLf & _
        vbTab & "<frameset id=""mainframe"">" & vbCrLf & _
        vbTab & vbTab & "<frame id=""left"">" & vbCrLf & _
        vbTab & vbTab & "<frame id=""right"">" & vbCrLf & _
        vbTab & "</frameset>" & vbCrLf & _
        "</frameset>"

    Set objFrames = ActiveDocument.body.all.tags("frameset").Item("topframe")
    objFrames.rows = "75,*"

    Set objFrames = ActiveDocument.body.all.tags("frameset").Item("mainframe")
    objFrames.cols = "145,*"

End Sub