IHTMLElement Object

Multiple objects
IHTMLElement
Multiple objects

Represents any HTML element in an HTML document.

While most HTML elements have a corresponding object, use the IHTMLElement object to access elements for which there isn't a corresponding object. For example, the HEAD element doesn't have a corresponding object in the Microsoft FrontPage Visual Basic for Applications (VBA) Page Object Model. In this case, to access the elements and properties related to the HEAD element, create an IHTMLElement object to access the HEAD element in a document.

Also use the IHTMLElement object to loop through objects in an IHTMLElementCollection collection that is made of of more than one type of element.

Using the IHTMLElement Object

Use the tags method to return an IHTMLElementCollection collection that represents a collection of a specific type of element in a document. Use the Item method to return an IHTMLElement object that accesses a specific element, referenced by ordinal number or by the value of the id attribute.

The following example accesses the HEAD element in the active document. While there is only one HEAD element in an HTML document, the tags method returns an IHTMLElementCollection collection, so the Item method accesses the first, which is also the only HEAD element in the document.

Dim objElement As IHTMLElement

Set objElement = ActiveDocument.all.tags("head").Item(0)

The following example uses the IHTMLElement object to loop through all the elements in the body of the active document and assign an id attribute based on the name of the element and the ordinal position of the element in the document.

Dim objElement As IHTMLElement
Dim intCount As Integer

For Each objElement In ActiveDocument.body.all
    intCount = intCount + 1
    objElement.Id = objElement.tagName & intCount
Next

Properties | all Property | children Property | className Property | Document Property | filters Property | id Property | innerHTML Property | innerText Property | isTextEdit Property | lang Property | language Property | offsetHeight Property | offsetLeft Property | offsetParent Property | offsetTop Property | offsetWidth Property | onafterupdate Property | onbeforeupdate Property | onclick Property | ondataavailable Property | ondatasetchanged Property | ondatasetcomplete Property | ondblclick Property | ondragstart Property | onerrorupdate Property | onfilterchange Property | onhelp Property | onkeydown Property | onkeypress Property | onkeyup Property | onmousedown Property | onmousemove Property | onmouseout Property | onmouseover Property | onmouseup Property | onrowenter Property | onrowexit Property | onselectstart Property | outerHTML Property | outerText Property | parentElement Property | parentTextEdit Property | recordNumber Property | sourceIndex Property | style Property | tagName Property | title Property

Methods | click Method | contains Method | getAttribute Method | insertAdjacentHTML Method | insertAdjacentText Method | removeAttribute Method | scrollIntoView Method | setAttribute Method | toString Method

Parent Objects | DispFPHTMLDocument Object | 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 | FPHTMLStyleSheet 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 | IFPDocument Object | IHTMLDocument2 Object | IHTMLElement Object | IHTMLEventObj Object | IHTMLStyleSheet Object

Child Objects | IHTMLElement Object | IHTMLFiltersCollection Object | IHTMLStyle Object