共用方式為


Document property

Gets the automation object of the active document, if any.

Syntax

Property values

Type: Object

the automation object.

Remarks

When the active document is an HTML page, this property provides access to the contents of the HTML Document Object Model (DOM). Specifically, it returns an IDispatch interface pointer to the HTMLDocument component object class (coclass). The HTMLDocument coclass is functionally equivalent to the Dynamic HTML (DHTML) document object used in HTML script. It supports all the required properties and methods to access the entire contents of the active HTML document.

C++ programs can get the Component Object Model (COM) interfaces IHTMLDocument, IHTMLDocument2, and IHTMLDocument3 by calling QueryInterface on the IDispatch received from this property.

When other document types are active, such as a Microsoft Word document, this property returns the default IDispatch dispatch interface (dispinterface) pointer for the hosted document object. For Word documents, this is functionally equivalent to the Document object in the Word object model. For more information on the Microsoft Office DOM, refer to the Microsoft Office Developer Center

Warning   If the document object type is not safe for scripting, this method returns successfully but sets ppDisp to Null. For Internet Explorer 7 and later, the return code is S_FALSE rather than S_OK. For more information, see Safe Initialization and Scripting for ActiveX Controls.

 

When the active document is an HTML page, this property provides access to the contents of the HTML DOM. Specifically, it returns an HTMLDocument object reference. The HTMLDocument object is functionally equivalent to the HTML document object used in HTML page script. It supports all the properties and methods necessary to access the entire contents of the active HTML document.

Microsoft Visual Basic programs that early bind to the HTMLDocument object can reference it through the IHTMLDocument interface, the IHTMLDocument2 interface, and the IHTMLDocument3 interface.

When other document types are active, such as a Word document, this property returns the document automation object of that document. For Word documents, this is the Document object. For more information on the Office DOM, refer to the Microsoft Office Developer Center.

Warning   If the document object type is not marked safe for scripting, this property returns Nothing. For more information, see Safe Initialization and Scripting for ActiveX Controls.

 

See also

InternetExplorer

WebBrowser

Reference

Application

Container

Parent