Page tree
Skip to end of metadata
Go to start of metadata

Description

Represents a Word document.

C#
vb.net

Remarks

To create a new document, use WordApplication.Create(). To open an existing document, use WordApplication.Open().

Note: Document inherits from Element and inherits a lot basic functionality from that class. Be sure to see the Element API docs when looking for specific functionality.

Examples

C#
vb.net

Properties

Name

Description

AutoformatType

Sets or returns a Document.Autoformat object representing autoformat type for this document. Possible values: Normal, Letter, Email.

CompatibilitySettings

Returns a CompatibilitySettings object that can be used to get and set various settings that help Word display documents that were imported from earlier versions and competing products.

ChangeTracking

Returns a WordChangeTracking object that can be used to get and set the change tracking settings for this Document.

DateCreated

Returns a DateTime object representing the date this document was created.

DatePrinted

Returns a DateTime object representing the date this document was last printed using Word.

DateRevised

Returns a DateTime object representing the date this document was last revised.

DefaultTabWidth

Sets or returns an int representing the default tab width for this Document. The value that is returned is in twips. One twip = (1/20 pt) or ( 1/1440 in).

DocumentProperties

Returns a Styles object that represents the properties of this document.

DocumentProtection

Returns a DocumentProtection object that can be used to get and set the protection settings that Word will apply to this document. (Only applicable to Word 2000 or above documents.)

GutterPosition

Sets or returns a Document.Gutter object representing the gutter position in this document when it is opened in Word. If you have set up your document with facing pages or two pages per sheet (by using Mirror margins, Book fold, or 2 pages per sheet), then this option is not available. Possible values: Side, Top.

HyphenSettings

Returns a WordHyphenSettings object that can be used to get and set the hyphenation settings for this Document.

MergeStylesFromTemplate

Sets or returns a boolean representing if Word will update the styles in the current document to match the styles in the attached Word template (i.e. Normal.dot) each time you open the document in Word. This should be set to true when you want to ensure that your document contains up-to-date style formatting.

NumCharacters

Returns an int representing the number of characters in this document.

NumPagesOnLastOpen

Returns an int representing the number of pages this document had when it was last opened in Word.

NumParagraphs

Returns an int representing the number of paragraphs in this document.

NumWords

Returns an int representing the number of words in this document.

PrintDataInFormFields

Sets or returns a boolean representing if Word will only print the data inside a form field in this document. This is typically used to print the data entered into an online form without printing the online form.

PrintFacingPages

Sets or returns a boolean representing if the headers and footers should be different for odd and even pages, such as when the pages in this document will be mirrored. When set to true, it creates one header or footer for even-numbered pages and a different header or footer for odd-numbered pages.

SaveDataInFormField

Sets or returns a boolean representing if Word will save only the data entered into a form field (instead of the field itself) for this document. When this is set to true, Word saves the data entered into an online form as a single, tab-delimited record so you can use it in a database. Word saves the file in Text Only file format.

Sections

Returns an array of Section objects that represents all the sections in this Document.

Styles

Returns a Styles object that represents the Styles embedded in this document.

UseWidowControl

Sets or returns a boolean representing if widow control is in effect for this Document.

ViewSettings

Returns a WordViewSettings object that can be used to get and set various settings that pertain to how Word will display this document.

Watermark

Returns a Watermark object representing an image or text that appears in the background of a printed document.

Methods

Name

Description

Append(Document)

Appends an existing Document to the end of the current Document, separated by a next-page section break

CreateDataImportProperties()

Returns a DataImportProperties object, which you can then use to set options for importing data into a table in a Word document.

CreateFont()

Returns a Font object based on the font used by the Normal Style. You can then change the properties of this font and use it elsewhere.

CreateParagraphFormatting()

Returns a ParagraphFormatting object based on the paragraph formatting used by the BodyText style. You can then change the properties of this font and use it elsewhere.

CreateTableFormatting()

Returns a TableFormatting object that represents the table formatting used by the NormalTable style.

GetBookmark(String)

Returns a Bookmark object that represents the bookmark in this document that has the specified name.

GetVariable(String)

Returns the document variable specified by name.

SetVariable(String, String)

Sets the value of the variable with the specified name. If the variable does not exist, setVariable creates a new variable. If the variable does exist, setVariable overwrites the existing variable.

Nested Classes

Name

Description

Autoformat

A Document.Autoformat value specifies the type of AutoFormat settings to apply to a document. To select an AutoFormat type in Microsoft Word:

Gutter

A Document.Gutter value specifies the position of a document's gutter margin. Gutter margins are used in documents that will be bound. A gutter margin is an extra margin on the top or side of the page that ensures that the text is not obscured when the document is bound.