Share via


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

Applies to | FPHTMLAnchorElement Object | FPHTMLAreaElement Object | FPHTMLBaseElement Object | FPHTMLBaseFontElement Object | FPHTMLBGsound Object | FPHTMLBlockElement Object | FPHTMLBody Object | FPHTMLBRElement Object | FPHTMLButtonElement Object | FPHTMLCommentElement Object | FPHTMLDDElement Object | FPHTMLDivElement Object | FPHTMLDivPosition Object | FPHTMLDListElement Object | FPHTMLDocument Object | FPHTMLDTElement Object | FPHTMLEmbed Object | FPHTMLFieldSetElement Object | FPHTMLFontElement Object | FPHTMLFormElement Object | FPHTMLFrameBase Object | FPHTMLFrameElement Object | FPHTMLFrameSetSite Object | FPHTMLFrontPageBotElement Object | FPHTMLHeaderElement Object | FPHTMLHRElement Object | FPHTMLIFrame Object | FPHTMLImg Object | FPHTMLInputButtonElement Object | FPHTMLInputFileElement Object | FPHTMLInputHiddenElement Object | FPHTMLInputImage Object | FPHTMLInputTextElement Object | FPHTMLIsIndexElement Object | FPHTMLLabelElement Object | FPHTMLLegendElement Object | FPHTMLLIElement Object | FPHTMLLinkElement Object | FPHTMLListElement Object | FPHTMLMapElement Object | FPHTMLMarqueeElement Object | FPHTMLMetaElement Object | FPHTMLNextIdElement Object | FPHTMLNoShowElement Object | FPHTMLObjectElement Object | FPHTMLOListElement Object | FPHTMLOptionElement Object | FPHTMLParaElement Object | FPHTMLPhraseElement Object | FPHTMLScriptElement Object | FPHTMLSelectElement Object | FPHTMLSpanElement Object | FPHTMLSpanFlow Object | FPHTMLStyleElement Object | FPHTMLTable Object | FPHTMLTableCaption Object | FPHTMLTableCell Object | FPHTMLTableCol Object | FPHTMLTableRow Object | FPHTMLTableSection Object | FPHTMLTemplateRegionElement Object | FPHTMLTextAreaElement Object | FPHTMLTextElement Object | FPHTMLTitleElement Object | FPHTMLUListElement Object | FPHTMLUnknownElement Object | FPHTMLWebPartElement Object | FPHTMLWebPartZoneElement Object | FPHTMLXSLElement Object | FPHTMLXSLWebPartElement Object | IHTMLDocument2 Object | IHTMLElement Object