CorelDRAW VBA Object Model Controls Guide
This article provides a comprehensive overview of the CorelDRAW Visual Basic for Applications (VBA) object model, detailing the core objects, collections, and structural controls used to automate graphic design workflows. By understanding this hierarchical model, developers can manipulate documents, vector shapes, layers, fills, and application-level settings directly through code.
The CorelDRAW VBA object model is structured hierarchically. Automation starts at the global application level and drills down into individual vector nodes and styling attributes. The primary objects that control CorelDRAW via VBA include:
1. Application Object
The Application object is the root of the hierarchy. It
controls global settings, window states, active documents, and global
automation processes.
- Key Properties:
ActiveDocument,ActiveWindow,Documents,Version. - Key Methods:
CreateDocument,OpenDocument,Quit.
2. Document and Documents Collection
The Document object represents an individual vector
graphic file. The Documents collection contains all
currently opened documents within the session.
- Key Properties:
Pages,MasterPage,ActivePage,Selection,Unit. - Key Methods:
Save,SaveAs,Close,PrintOut,Export.
3. Page and Layer Controls
CorelDRAW organizes visual assets using pages and hierarchical layers.
- Page Object: Represents an individual drawing page inside a document. Controls layout, orientation, and dimensions.
- Layer Object: Exists inside pages and controls
visibility, editability, and printing status of grouped shapes.
Properties include
Visible,Printable,Editable, andShapes.
4. Shape and ShapeRange Objects
Shapes are the primary visual building blocks in CorelDRAW, covering rectangles, ellipses, text, curves, and imported bitmaps.
- Shape Object: Represents a single element on a
layer. It holds geometric properties (
Left,Top,Width,Height,RotationAngle) and type-specific methods. - ShapeRange Object: A temporary collection of selected or targeted shapes. It allows simultaneous transformations (grouping, alignment, distribution, and boolean operations like weld, trim, and intersect).
5. Geometry Controls: Curve, SubPath, and Node
For precise vector manipulation, the object model provides access to individual path components:
- Curve: The mathematical path data of a vector shape.
- SubPath: Individual contiguous segments within a compound curve.
- Node: Individual control points that govern lines and Bézier curves, providing access to coordinates and control handles.
6. Appearance Controls: Fill and Outline
Styling is controlled via dedicated sub-objects attached to each shape:
- Fill Object: Manages the interior appearance, including uniform colors, fountain (gradient) fills, pattern fills, and transparency settings.
- Outline Object: Controls line properties, including stroke width, color, dash patterns, and line cap/corner styles.
7. Color and Palette Objects
Color values are controlled precisely to maintain print and digital accuracy:
- Color Object: Represents specific color definitions across various models such as CMYK, RGB, Grayscale, or spot color systems (e.g., PANTONE).
- Palette Object: Provides access to system and document color swatches.
8. Text Controls: Text and TextRange
Text elements expose an internal hierarchy for typographic manipulation:
- Text Object: Contains the complete textual content of artistic or paragraph text frames.
- TextRange Object: Allows character-, word-, or paragraph-level formatting, including font family, point size, kerning, tracking, and alignment.
9. UserForm and UI Controls
In addition to drawing objects, CorelDRAW VBA includes the standard Microsoft Forms 2.0 object library. This enables macro developers to build custom user interfaces using controls such as:
CommandButton,TextBox, andLabelListBoxandComboBoxCheckBoxandOptionButtonFrame,MultiPage, andScrollBar
These UI controls trigger custom procedures that read and modify the document's underlying vector object model.