Partager via


Document Object Properties

If the application is document based, it should provide a Document object named Document. Use a different name only if Document is inappropriate (for example, if the application uses highly technical or otherwise specialized terminology within its user interface).

The Document object should have the properties listed in the table that follows. The properties Application, FullName, Name, Parent, Path, and Saved are required; other properties are optional.

Property name Return type Description
Application
VT_DISPATCH
Returns the Application object; read only. Required.
Author
VT_BSTR
Sets or returns summary information about the document's author; read/write.
Comments
VT_BSTR
Sets or returns summary information comments for the document; read/write.
FullName
VT_BSTR
Returns the file specification of the document, including the path; read only. Required. (See Comments section below.)
Keywords
VT_BSTR
Sets or returns summary information keywords associated with the document; read/write.
Name
VT_BSTR
Returns the file name of the document, not including the file's path specification; read only.
Parent
VT_DISPATCH
Returns the Parent property of the Document object; read only. Required.
Path
VT_BSTR
Returns the path specification for the document, not including the file name or file name extension; read only. Required. (See Comments section below.)
ReadOnly
VT_BOOL
Returns True if the file is read only, otherwise False; read only.
Saved
VT_BOOL
Returns True if the document has never been saved, but has not changed since it was created. Returns True if it has been saved and has not changed since last saved. Returns False if it has never been saved and has changed since it was created; or if it was saved, but has changed since last saved. Read only; required.
Subject
VT_BSTR
Sets or returns summary information about the subject of the document; read/write.
Title
VT_BSTR
Sets or returns summary information about the title of the document; read/write.

Comments

Properties or methods that disclose information about local directory structures or file systems can leave your system vulnerable to attack. Security precautions, such as authenticating callers, can help reduce the risk of revealing sensitive information.

The Document object should have the methods listed in the following table. The methods Activate, Close, Print, Save, and SaveAs are required; other methods are optional.

Method name Return type Description
Activate
VT_EMPTY
Activates the first window associated with the document. Required.
Close
VT_EMPTY
Closes all windows associated with the document and removes the document from the Documents collection. Required. Takes two optional arguments, saveChanges (VT_BOOL) and filename (VT_BSTR). The filename argument specifies the name of the file in which to save the document.
NewWindow
VT_EMPTY
Creates a new window for the document.
Print
VT_EMPTY
Prints the document. Required. Takes three optional arguments: from (VT_I2), to (VT_I2), and copies (VT_I2). The from and to arguments specify the page range to print. The copies argument specifies the number of copies to print.
PrintOut
VT_EMPTY
Same as Print method, but provides an easier way to use the method in Visual Basic, because Print is a Visual Basic keyword.
PrintPreview
VT_EMPTY
Previews the pages and page breaks of the document. Equivalent to clicking Print Preview on the File menu.
RevertToSaved
VT_EMPTY
Reverts to the last saved copy of the document, and discards any changes.
Save
VT_EMPTY
Saves changes to the file specified in the document's FullName property. Required.
SaveAs
VT_EMPTY
Saves changes to a file. Required. Takes one optional argument, filename (VT_BSTR). The filename argument can include an optional path specification.