Working with documents
Working with documents
Whenever a CorelDRAW file is opened, a new Document object is created in the Application object for that document. The Application object contains a Documents collection, which provides access to all of the open documents. The order of the documents in the collection is set to the order in which the documents were created and opened.
You can browse the object model for the complete list of Document objects, but here is a list of the most useful ones (some of which are explained in greater detail in this chapter):
Document Member
Description
Activate Activates the given document, bringing it to the front of the pile in CorelDRAW . ActiveDocument is set to reference it.
ActiveLayer Represents the layer that is set as active in the Object Manager ActivePage
Represents the active page in the document — that is, the one that is being edited in CorelDRAW
AddPages
Adds pages to the end of a document
AddPagesEx BeginCommandGroup
Creates a “command group” — that is, a series of actions that appear as a single item EndCommandGroup
on the Undo list
ClearSelection Clears the document’s selection so as to deselect all shapes in the document Close
Closes the document
Export
Performs a simple export from the document
ExportEx
Performs a highly configurable export from the document
ExportBitmap
Performs an export to a bitmap with full control
FileName
Gets the filename
FilePath
Gets the path to the file
FullFileName
Gets the full path and filename of the document
GetUserArea Lets you add interactivity to a macro by allowing the user to drag an area GetUserClick
Lets you add interactivity to a macro by allowing the user to click InsertPages
Inserts pages into the document at a specified location
InsertPagesEx Pages
Provides access to the Pages collection
PrintOut
Prints the document using the document’s print settings
PrintSettings PublishToPDF
Publishes the document to Adobe Acrobat Reader (PDF) format PDFSettings
ReferencePoint Gets/sets the reference point used by many Shape functions (such as the ones for transforming a shape or getting a shape’s position)
Save
Saves the document using the current filename
SaveAs Saves the document to a new filename or with new settings Selection
Gets the selection as a Shape
Document Member
Description
SelectionRange
Gets the selection as a ShapeRange
Unit Sets the document units used by functions that take a measurement value, such as WorldScale
functions related to size and position. This is independent of the units that the rulers are set to use. Also gets/sets the drawing scale. This changes the value in the document; however, it must be explicitly calculated into functions that take a measurement value, which use 1:1 by default.
The Application object also contains all Window objects. Document and Window objects have many member properties and methods for performing actions such as the
following: • Creating documents • Opening documents • Importing files into documents • Switching between documents • Viewing documents • Changing content in documents • Setting the Undo string for documents • Exporting files from documents • Printing documents • Publishing documents to PDF • Closing documents