Forums     Knowledge Base     OfficeWriter Online     
 
 
This documentation is for
OfficeWriter v3.8.1
.NET Platform

View Docs for Another
Version or Platform

Programmer's Reference > WordApplication API > Document

The Document Object

     extends Element



Represents a Word document.

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:

[csharp]
// Create a new Word document
WordApplication app = new WordApplication();
Document doc = app.Create();

// Open an existing Word document
WordApplication app = new WordApplication();
Document doc = app.Open(@"C:\sample.doc");
[vbnet]
' Create a new Word document
Dim app As New WordApplication()
Dim doc As Document = app.Create()

' Open an existing Word document
Dim app As New WordApplication()
Dim doc As Document = app.Open("C:\sample.doc")


Please note that this object inherits methods and properties not shown here from the following objects:

Document Enumerations

NameDescription
Document.Autoformat

A Document.Autoformat value specifies the type of AutoFormat settings to apply to a document

Document.Gutter

A Document.Gutter value specifies the position of a document's gutter margin



Document Properties

Property Type Access Description
AutoformatType Document.Autoformat read
write

Sets or returns a Document.Autoformat object representing autoformat type for this document

Bookmark Bookmark read

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

ChangeTracking WordChangeTracking read

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

CompatibilitySettings CompatibilitySettings read

Returns an 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

DateCreated Date read

Returns a DateTime object representing the date this document was created

DatePrinted Date read

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

DateRevised Date read

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

DefaultTabWidth int read
write

Sets or returns an int representing the default tab width for this Document

DocumentProperties DocumentProperties read

Returns an Styles object that represents the properties of this document

DocumentProtection DocumentProtection read

Returns an DocumentProtection object that can be used to get and set the protection settings that Word will apply to this document

GutterPosition Gutter read
write

Sets or returns a Document.Gutter object representing the gutter position in this document when it is opened in Word

HyphenSettings WordHyphenSettings read

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

MergeStylesFromTemplate boolean read
write

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

NumCharacters int read

Returns an int representing the number of characters in this document

NumPagesOnLastOpen int read

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

NumParagraphs int read

Returns an int representing the number of paragraphs in this document

NumWords int read

Returns an int representing the number of words in this document

PrintDataInFormFields boolean read
write

Sets or returns a boolean representing if Word will only print the data inside a form field in this document

PrintFacingPages boolean read
write

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

SaveDataInFormField boolean read
write

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

Sections Section[] read

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

Styles Styles read

Returns an Styles object that represents the Styles embedded in this document

UseWidowControl boolean read
write

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

ViewSettings WordViewSettings read

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

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


Document Methods

ReturnsSignature and Description
DataImportProperties CreateDataImportProperties ( )

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

Font CreateFont ( )

Returns a Font object based on the font used by the Normal Style

ParagraphFormatting CreateParagraphFormatting ( )

Returns a ParagraphFormatting object based on the paragraph formatting used by the BodyText style

TableFormatting CreateTableFormatting ( )

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

String GetVariable ( String name )

Returns the document variable specified by name

void SetVariable ( String name , String val )

Sets the value of the variable with the specified name



Copyright 2007 © SoftArtisans, Inc. All Rights Reserved.