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
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 | 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 | IHTMLElement Object