CreateNewDoc Method

Creates a new document and makes it active. Returns an instance of the Document object which corresponds to the created document.

Applies to: Application object

Syntax

[[Set] documentRet =] object.CreateNewDoc ()

The CreateNewDoc method syntax has these parts:

Part Description
object Required. An expression that returns an instance of the Application object.
documentRet

Optional. A Document type variable.

Remarks

A new document is created based on the default settings or from a template file. It's added to the end of the document collection of the application. So, the expression below returns the most recent created or opened document:

thisApp.Doc( thisApp.DocsNum() ) ' returns most recent created or opened document

Example

This example contains an application-level script. It demonstrates using the CreateNewDoc method. The script creates a new document, which contains the shape with "New Document" text on the first page.

Dim newDoc as Document              ' Declare variables
Dim shp_rect As Shape

Set newDoc = thisApp.CreateNewDoc() ' Create a new document
newDoc.PageSizeX = 700 ' Set page width for the document
newDoc.PageSizeY = 700 ' Set page height for the document ' Draw a rectangle with "New Document" text Set shp_rect = newDoc.Page(1).DrawRect( 50,50, newDoc.PageSizeX-50, newDoc.PageSizeY-50 ) Set shp_rect.Text = "New Document"

 

See Also

CloseDoc method, Doc method, DocByName method, DocsNum method, FirstDoc method, NextDoc method, OpenDoc method, Document object