all Property

Microsoft FrontPage Visual Basic

all Property

Returns an IHTMLElementCollection object that represents a reference to the collection of all elements contained within a specified object.

expression.all

expression    Required. An expression that returns one of the objects in the Applies To list.

Remarks

The IHTMLElementCollection object includes one element object for each valid HTML tag. If a valid tag has a matching end tag, both tags are represented by the same element object.

The collection returned when you use the all property of an FPHTMLDocument or IHTMLDocument object always includes a reference to the HTML, HEAD, TITLE, and BODY elements, regardless of whether the tags are present in the document.

If the document contains invalid or unknown tags, the collection includes one element object for each. Unlike valid end tags, unknown end tags are represented by their own IHTMLElement objects. The order of the elements in an IHTMLElementCollection object is the same order in which the elements occur in the HTML source code. Although the IHTMLElementCollection object indicates the order of the tags, it does not indicate hierarchy. This behavior is different from the children property, which returns an IHTMLElementCollection object that represents only the top-level elements that are direct descendants of the specified element and not any nested elements.

Example

The following example builds and inserts a table into the specified document. The function takes an IHTMLElement object (which can be any element in a document), two integers for the number of rows and columns, and a string for the id attribute of the table, and then returns an FPHTMLTable object that represents the newly created table.

    Function InsertTable(objElement As IHTMLElement, intRows As Integer, _
        intCols As Integer, strID As String) As FPHTMLTable
    Dim objTable As FPHTMLTable
    Dim strTable As String
    Dim intRow As Integer
    Dim intCol As Integer
    
    strTable = "<TABLE id=""" & strID & """>" & vbCrLf
    
    For intRow = 0 To intRows - 1
        strTable = strTable & vbTab & "<TR>" & vbCrLf
        For intCol = 0 To intCols - 1
            strTable = strTable & vbTab & vbTab & "<TD width=""50"">&nbsp;</TD>" & vbCrLf
        Next
        strTable = strTable & vbTab & "</TR>" & vbCrLf
    Next
    
    strTable = strTable & "</TABLE>"
    
    If objElement.tagName = ActiveDocument.activeElement.tagName Then
        objElement.insertAdjacentHTML "afterend", strTable
    Else
        objElement.insertAdjacentHTML "beforeend", strTable
    End If
    
    Set InsertTable = objElement.Document.all.tags("table").Item(CVar(strID))
End Function
  

Use the following example to call the preceding subroutine.

    Sub CallInsertTable()
    Dim objTbl As FPHTMLTable

    Set objTbl = InsertTable(ActiveDocument.activeElement, _
        4, 3, "testtbl")

    objTbl.bgColor = "red"
End Sub