Share via

IHTMLDocument2 Object

Multiple objects
Multiple objects

Represents the active HTML document. The IHTMLDocument2 object contains property information related to the HTML in a Web page such as background color, link color, and style sheet as well as methods that act on the data such as the CreateElement and ExecCommand methods.

The IHTMLDocument2 object provides access to a limited number of properties and methods that relate to a Web page. For access to all properties and methods, use the FPHTMLDocument object.

Using the IHTMLDocument2 object

Use the ActiveDocument property of the Application object or the Document property of the PageWindowEx object ****to return an IHTMLDocument2 object. The following example accesses the active document by using the ActivePageWindow property.

Dim objDoc As IHTMLDocument2

Set objDoc = ActivePageWindow.Document

The following example accesses the active document by using the ActiveDocument property.

Dim objDoc As IHTMLDocument2

Set objDoc = ActiveDocument

Note  There is no way to access the contents of a Web page using Visual Basic for Applications (VBA) in Microsoft FrontPage without first opening the document and setting it as the active document using either the ActivePageWindow property, as shown in the preceding example, or the ActiveDocument property.


The PageWindowEx object, in the FrontPage Web Object Model, contains both an ActiveDocument property and a Document property. Both properties return an IHTMLDocument2 object. However, when a FRAMESET element is contained within a page, the Document property returns the page containing the FRAMESET element, and the ActiveDocument property returns the page referenced in the SRC attribute of the FRAME element located at the current insertion point position.

Properties | activeElement Property | alinkColor Property | all Property | anchors Property | applets Property | bgColor Property | Body Property | cookie Property | defaultCharset Property | domain Property | embeds Property | fgColor Property | fileCreatedDate Property | fileModifiedDate Property | fileSize Property | fileUpdatedDate Property | forms Property | frames Property | images Property | lastModified Property | linkColor Property | links Property | location Property | mimeType Property | nameProp Property | onafterupdate Property | onbeforeupdate Property | onclick Property | ondblclick Property | ondragstart Property | onerrorupdate Property | onhelp Property | onkeydown Property | onkeypress Property | onkeyup Property | onmousedown Property | onmousemove Property | onmouseout Property | onmouseover Property | onmouseup Property | onreadystatechange Property | onrowenter Property | onrowexit Property | onselectstart Property | parentWindow Property | plugins Property | protocol Property | ReadyState Property | referrer Property | scripts Property | security Property | selection Property | styleSheets Property | title Property | URL Property | vlinkColor Property

Methods | clear Method | close Method | createElement Method | createStyleSheet Method | elementFromPoint Method | execCommand Method | execCommandShowHelp Method | open Method | queryCommandEnabled Method | queryCommandIndeterm Method | queryCommandState Method | queryCommandSupported Method | queryCommandText Method | queryCommandValue Method | toString Method | write Method | writeln Method

Parent Objects | FPHTMLWindow2 Object | FPHTMLWindowProxy Object | IHTMLWindow2 Object

Child Objects | IHTMLElement Object | IHTMLElementCollection Object | IHTMLFramesCollection2 Object | IHTMLLocation Object | IHTMLSelectionObject Object | IHTMLStyleSheetsCollection Object | IHTMLWindow2 Object