Quick links to procedures on this page:

 
 
 
 
 
 
 
 
 
 

Working with macros

You can save time by using a macro to automate a series of repetitive tasks. A macro lets you specify a sequence of actions so that you can quickly repeat those actions later.

You don’t need any programming experience to use macros — in fact, the basic tools for working with macros are available within the main application window. However, if you want to have more control over your macros, you can use the following built-in programming environments:

 
Microsoft Visual Basic for Applications (VBA) — a subset of the Microsoft Visual Basic (VB) programming environment, and an excellent choice for beginners. You can use VBA to create basic macros for personal use, but you can also use it to create more advanced macro projects.
 
Microsoft Visual Studio Tools for Applications (VSTA) — the successor to VBA, and an excellent choice for developers and other programming experts. VSTA provides the tools and features that you need to create the most advanced kinds of macro projects.
For detailed information on the differences between VBA and VSTA, please see the Corel DESIGNER Macros Help file (des_om.chm, which is located in the Data folder for the installed software).
Getting started with macros

The macro features for VBA and VSTA are installed with the software by default, but you can manually install these features if necessary. You can specify options for the VBA feature.

The macro features provide several tools for working with macros in the main application window:

 
Macros toolbar — provides easy access to common macro functions
 
Macro Manager docker — provides easy access to all available macro projects for VBA, and to basic functions for working with those projects
 
Macro Editor (formerly the Visual Basic Editor) — provides advanced functions for creating VBA-based macro projects
 
VSTA Editor — provides advanced functions for creating VSTA-based macro projects
Creating macros

Macros are stored in modules (also called “code modules”), which are stored in macro projects. The Macro Manager docker lets you view and manage all of the macro projects, modules, and macros that are available to you.

You can use the Macro Manager docker to create macro projects in the form of Global Macro Storage (GMS) files. Using a GMS file is an excellent way to bundle the components of your macro project for sharing with others. You can use the Macro Manager docker to open (or “load”) the macro projects that you create, as well as the macro projects that install with the software or that are otherwise made available to you. You can also use the Macro Manager docker to rename macro projects, as well as to copy and close (or “unload”) GMS-based macro projects.

Some macro projects are locked and cannot be modified.
When you create a document, a macro project for that document is automatically added to the Macro Manager docker. Although you can store macros within the macro project for a document — for example, to create an all-in-one template — it is recommended that you instead use GMS files to store your macro projects.

Each macro project contains at least one module. You can use the Macro Manager docker to add a module to a VBA-based macro project, or to open existing VBA modules for editing. You can also use the Macro Manager docker to rename or delete VBA modules.

The editing feature is disabled for some modules.

Finally, you can use the Macro Manager docker to create macros within the available modules. You don’t need any programming experience to create macros; however, if you have programming experience and want to edit VBA macros, you can do so by using the Macro Editor. You can also use the Macro Manager docker to rename and delete VBA macros.

Corel DESIGNER includes sample macros, which supply additional functionality, demonstrate automation in the software, and provide sample code. For information on these sample macros, please see the Corel DESIGNER Macros Help file (des_om.chm, which is located in the Data folder for the installed software).
Recording macros

You can record macros and save them for later use.

You can also record temporary macros for actions that you need to repeat only a few times. A temporary macro is accessible until a new temporary macro is recorded.

The recording feature is disabled for some macro projects.
Before recording a macro, make sure that you know exactly which actions you want to record and the order in which you want to record them. When you start recording, the macro recorder captures every change that you make in a drawing. For example, if you create a shape, resize the shape, and then change its color, the macro records all the changes. When you are done making the changes, you must stop recording the macro.
Playing macros

You can perform the actions that are associated with a macro by playing that macro.

You can also play a temporary macro.

Learning more about macros

Corel DESIGNER provides additional resources that contain helpful information about macros. These additional resources, which are located in the Data folder for the installed software, are described in the following table.

Resource
Description and filename
Macros Help file
Provides detailed information about the features and functions for creating macro projects in Corel DESIGNER
des_om.chm
Macro Programming Guide
Provides an instructional approach to creating macro projects for Corel DESIGNER
Macro Programming Guide.pdf
Object Model Diagram
Provides a hierarchical representation of the features and functions that can be automated in Corel DESIGNER
Corel DESIGNER Object Model Diagram.pdf

The Macros Help file includes documentation on every feature and function that can be automated in the application. (Collectively, these features and functions are called an “object model.”) You can easily access the Macros Help file from within the Macro Editor.

For more detailed information about VBA and its programming environment, please consult the Microsoft Visual Basic Help from the Help menu in the Macro Editor.
For more detailed information about VSTA and its programming environment, please consult the Help menu in the VSTA Editor.
To manually install the macro features Back to Top
1.
 
Insert the installation disc into your computer.
If the installation wizard does not start automatically, locate and run the Setup.exe file on the installation disc.
2.
 
Follow the on-screen instructions for modifying the software.
3.
 
On the Features page of the setup, enable the following check boxes in the Utilities list box:
Visual Basic for Applications
Visual Studio Tools for Applications
The macro features for VBA and VSTA are installed with the software by default.
To specify VBA options Back to Top
1.
 
Click Tools Options.
2.
 
In the Workspace list of categories, click VBA.
3.
 
In the Security area, specify how to control the risk of running malicious macros by clicking Security options.
If you want to bypass this security feature, enable the Trust all installed GMS modules check box, and then proceed to step 6.
4.
 
On the Security level page of the Security dialog box, enable one of the following options:
Very high — allows only macros installed in trusted locations to run. All other signed and unsigned macros are disabled.
High — allows only signed macros from trusted sources to run. Unsigned macros are automatically disabled.
Medium — lets you choose which macros run, even if they are potentially harmful
Low (not recommended) — allows all potentially unsafe macros to run. Enable this setting if you have virus-scanning software installed, or if you check the safety of all documents that you open.
5.
 
On the Trusted publishers page of the Security dialog box, review which macro publishers are trusted. Click View to display details on the selected macro publisher, or click Remove to delete the selected macro publisher from the list.
If desired, you can enable or disable the Trust access to Visual Basic project check box for the selected macro publisher.
6.
 
Disable the Delay load VBA check box if you want to load the VBA feature at start-up.
To access the macro tools Back to Top

To
Do the following
Display the Macros toolbar
Click View Toolbars Macros.
A check mark next to the command indicates that the toolbar is displayed.
Display the Macro Manager docker
Do one of the following:
 
Click Tools Macros Macro Manager.
 
Click the Macro Manager button on the Macros toolbar.
Display the Macro Editor
Do one of the following:
 
Click Tools Macros Macro Editor.
 
Click the Macro Editor button on the Macros toolbar.
 
Right-click Visual Basic for Applications in the Macro Manager docker, and then click Show IDE.
Display the VSTA Editor
Click Tools Macros VSTA Editor.

To create a macro project Back to Top
 
In the Macro Manager docker, do one of the following:
Click Visual Basic for Applications in the list, click New, and then click New macro project.
Right-click Visual Basic for Applications in the list, and then click New macro project.

You can also
 
Open (or “load”) a macro project
Do one of the following:
 
Click Visual Basic for Applications in the list, click Load, and then choose the project.
 
Right-click Visual Basic for Applications in the list, click Load macro project, and then choose the project.
Rename a macro project
Right-click the project in the list, and then click Rename.
Copy a GMS-based macro project
Right-click the project in the list, click Copy to, and then choose the target location for the copied project.
NOTE: You cannot copy a document-based macro project. Such projects are stored within a document and cannot be managed separately from that document.
Display or hide all modules in the list
Click the Simple mode button .
Add a module to a macro project
Do one of the following:
 
Click the project in the list, click New, and then click New module.
 
Right-click the project in the list, and then click New module.
Edit a module in a macro project
Do one of the following:
 
Click the module in the list, and then click the Edit button .
 
Right-click the module in the list, and then click Edit.
Rename a module in a macro project
Right-click the module in the list, and then click Rename.
Delete a module from a macro project
Do one of the following:
 
Click the module in the list, and then click the Delete button .
 
Right-click the module in the list, and then click Delete.
Close (or “unload”) a GMS-based macro project
Right-click the macro project in the list, and then click Unload macro project.
NOTE: You can close a document-based macro project only by closing the document in which it is stored.

Some macro projects are locked and cannot be modified.
To create a macro Back to Top
 
In the Macro Manager docker, do one of the following:
Click the desired container module, click New, and then click New macro.
Right-click the desired container module, and then click New macro.

You can also
 
Edit a macro
Do one of the following:
 
Click the macro in the list, and then click the Edit button .
 
Right-click the macro in the list, and then click Edit.
Delete a macro
Do one of the following:
 
Click the macro in the list, and then click the Delete button .
 
Right-click the macro in the list, and then click Delete.

Some macro projects are locked and cannot be modified.
To record a macro Back to Top
1.
 
Do one of the following:
Click Tools Macros Start recording, or click the Start recording button on the Macros toolbar, to store the macro in the default macro project for recordings.
In the Macro Manager docker, click the project in which to store the macro, and then click the Record button .
The Record macro dialog box appears.
2.
 
In the Macro name box, type a name for the macro.
Macro names can contain numerals, but they must begin with a letter. Macro names cannot contain spaces or non-alphanumeric characters other than underscores ( _ ).
3.
 
Type a description of the macro in the Description box, and then click OK.
4.
 
Perform the actions that you want to record.
The application begins recording your actions. If you want to pause recording, do one of the following:
Click Tools Macros Pause recording. Repeat this step to resume recording.
Click the Pause recording button on the Macros toolbar or in the Macro Manager docker. Repeat this step to resume recording.
5.
 
To stop recording, do one of the following:
Click Tools Macros Stop recording.
Click the Stop recording button on the Macros toolbar or in the Macro Manager docker.
You cannot record a macro if all available macro projects are locked.
Not all actions can be recorded — some because of their complexity (although many such actions can be manually coded in the Macro Editor). When an action cannot be recorded, a comment is placed in the macro code (“The recording of this command is not supported.”), but the recording process continues until you stop it. You can view any comments in the code by opening the macro in the Macro Editor.
You can specify the default macro project for recordings by right-clicking the project in the Macro Manager docker, and then clicking Set as recording project. However, you cannot specify a locked macro project.
You can cancel recording a macro, and discard any commands recorded thus far, by clicking Tools Macros Cancel recording.

You can also
 
Save the actions in the Undo list as a VBA macro
Click Tools Undo, perform the actions that you want to record, and then click the Save list to a VBA macro button in the Undo docker.

To record a temporary macro Back to Top
1.
 
Click Tools Macros Record temporary macro.
2.
 
Perform the actions that you want to record.
The application begins recording your actions. If you want to pause recording, do one of the following:
Click Tools Macros Pause recording. Repeat this step to resume recording.
Click the Pause recording button on the Macros toolbar or in the Macro Manager docker. Repeat this step to resume recording.
3.
 
To stop recording, do one of the following:
Click Tools Macros Stop recording.
Click the Stop recording button on the Macros toolbar or in the Macro Manager docker.
The macro is temporarily saved to the default recording project. When the current session is ended, the macro is deleted from that project.
You cannot record a temporary macro if all available macro projects are locked.
Not all actions can be recorded.
You can specify the default recording project by right-clicking the project in the Macro Manager docker, and then clicking Set as recording project. (You cannot specify a locked macro project.) If you want, you can create multiple temporary recordings by assigning each one to its own macro project.
You can cancel recording a macro, and discard any commands recorded thus far, by clicking Tools Macros Cancel recording.
To play a macro Back to Top
 
Do any of the following:
Click Tools Macros Run macro, or click the Run macro button on the Macros toolbar. From the Macros in list box, choose the project or file in which the macro is stored. From the Macro name list, choose the macro. Click Run.
In the Macro Manager docker, double-click the macro in the list.
In the Macro Manager docker, click the macro in the list, and then click the Run button .
In the Macro Manager docker, right-click the macro in the list, and then click Run.
To play a temporary macro Back to Top
 
Click Tools Macros Run temporary macro.
This option is enabled only after you record a temporary macro.
If you have created multiple temporary macros, you must specify which macro project contains the one that you want to run. Right-click the project in the Macro Manager docker, and then click Set as recording project.
To access the Macros Help file from within the Macro Editor Back to Top
1.
 
While in Microsoft Visual Basic for Applications, press F2 to display the Object Browser.
The Object Browser displays all the features and functions that can be automated in the Macro Editor.
2.
 
Choose Corel DESIGNER from the Library list box.
The Object Browser is updated to display only the features and functions of Corel DESIGNER that can be automated in the Macro Editor. Collectively, these features and functions are called an “object model.”
3.
 
Do one of the following:
Display the home page for the Macros Help file by pressing F1. You can browse the object-model documentation for the application by accessing the “Object Model Reference” section of the Help file.
Display the Help topic for a specific item in the Object Browser by clicking that item and pressing F1.
You can also display a Help topic for any item in the Code window of the Macro Editor by clicking that item and pressing F1.


Feedback
Was this page helpful? Send feedback.

Copyright 2013 Corel Corporation. All rights reserved.