children Property

Microsoft FrontPage Visual Basic

children Property

Returns an IHTMLElementCollection collection that represents a collection of elements that are direct descendants of a specified object.

expression.children

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

Remarks

If the document contains invalid or unknown tags, the IHTMLElementCollection object includes one element object for each. Unlike valid end tags, unknown end tags are represented by their own IHTMLElement objects. When you use the children property, the order of the elements in an object indicates the hierarchy and includes only the top-level elements that are direct descendants of the specified element and not any nested elements. This behavior is different from the all property, which returns an IHTMLElementCollection object that represents all tags regardless of hierarchy.

Example

The following example specifies the title of the page and the contents of the first heading to the specified string. Use the CallSetTitleAndFirstHeading subroutine following to call this function.

    Function SetTitleAndFirstHeading(ByRef objBody As FPHTMLBody, _
        ByVal strTitle As String) As Boolean
    
    Dim objHeading As IHTMLElement
    
    SetTitleAndFirstHeading = False
    
    Set objBody = ActiveDocument.body
    
    If InStr(1, UCase(objBody.innerHTML), UCase("h1")) < 1 Then
        objBody.insertAdjacentHTML "afterBegin", "<h1>" & strTitle & "</h1>"
    Else
        Set objHeading = objBody.Children.tags("h1").Item(0)
        objHeading.innerText = strTitle
    End If
        
    objBody.Document.Title = strTitle
    SetTitleAndFirstHeading = True
    
End Function
  

The following example calls the preceding SetTitleAndFirstHeading function and displays a message indicating whether the function was successful.

    Sub CallSetTitleAndFirstHeading()
    Dim blnResponse as Boolean

    blnResponse = SetTitleAndFirstHeading(objBody:=ActiveDocument.body, _
        strTitle:="FrontPage Developer's Home Page")

    If blnResponse = True Then
        MsgBox "You have successfully changed the title " & _
            "and first heading of the current page."
    Else
        MsgBox "Title and first heading were not changed."
    End If
End Sub