Previous Document Next Document

Understanding the CorelDRAW object model : Working with documents : Creating command groups for documents


Creating command groups for documents

Two very useful methods of the Document class combine to create a “command group,” which can reduce a series of programmed, document-related actions to a single, undoable step. These methods — BeginCommandGroup and EndCommandGroup — are demonstrated in the following VBA example:

Dim sh As Shape
ActiveDocument.BeginCommandGroup "CreateCurveEllipse"
Set sh = ActiveLayer.CreateEllipse(0, 1, 1, 0)
sh.ConvertToCurves
ActiveDocument.EndCommandGroup

The preceding code sets the Undo string in the Edit menu as Undo CreateCurveEllipse. Clicking this command undoes not only the ConvertToCurves operation but also the CreateEllipse operation.

A command group can contain many hundreds of commands, if required. Creating command groups can make your macros appear to be fully integrated into the application.

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.