Tuesday, 12 April 2011

How to create macro (creating project)

As a short introduction, a macro is series of commands that automate some task.
In case of Corel Draw it is program written in visual basic programming language.

How to create a macro?
Macros are stored in files with extension  '.gms '. There is one file provided by Corel called globalMacroStorage.gms.
This is first (1) place where you can save your macro.

Second (2) option is to create new file which represents new macro project.

Very basic (simplified) structure of  macro project is as follows:
  • Project contain: modules
  • modules contain:  subs (subroutines) in many cases these are  actual macros
(You will see later that the structure of project is much more complex)

1) GlobalMacroStorage.gms

Go to:    main menu >> Tools >> Macros >> and choose Macro Manager

You should see new pop-up window or docker on the right hand side with the list of all macro projects in it.

Find the 'GlobalMacroStorage' and click the little cross next to see modules.

On the top of this window click 'New' button and then module.
While newly created module is selected repeat operation but this time select macro.

It opens the macro editor where you can write or edit your macro.

Sub nameOfMacro()  'Sub states for subroutine.

'Code here

End Sub

2) Creating new macro project

The procedure is pretty much the same except your first choice after clicking the 'New' button is 'Macro Project'.

You will be prompt to name and save new .gms file. The dialog box will display right location, which is: 

Windows XP: C:\Documents and Settings\'user nick name'\Application Data\Corel\CorelDRAW Graphics Suite X5\Draw\GMS

Windows Vista: C:\Users\'user nick name'\AppData\Roaming\Corel\CorelDRAW Graphics Suite X5\User Draw\GMS

Windows 7: C:\Users\'user nick name'\AppData\Roaming\Corel\CorelDRAW Graphics Suite X5\Draw\GMS

Form there Corel Draw loads your project at start up.

Rest procedure of creating new macro is the same as for 1) GlobalMacroStorage.gms

For the summary see this short video:


The first macro code will be explained in the next post. 

Another way to create new macro project is to  create simple text file and change it's extension to '.gms', and place it in same location as previous plus alternatively:

Windows XP: C:\Program Files\Corel\CorelDRAW Graphics Suite X5\Draw\GMS

The file is loaded at Corel start up (you can load it manually via macro manager by clicking the 'Load' button next to 'New' and navigate to .gms file), and then you can edit it in macro editor - main menu >> Tools >> Macros >>  Macro Editor.



  1. activelayer.CreateArtisticText x,y -(1.6 (fontSize/4)) 'Which code ? ... Please answer my question

    1. I don't understand your question please clarify

  2. ActiveLayer.CreateArtisticText x, y - (1.6 * (fontSize / 4)) .......... ????

    In the video we can't see the other part of the code, please publish the code of tha last line.

  3. the whole code of the macro is in the next post:

    and this line of the code is:
    ActiveLayer.CreateArtisticText x, y - (1.6 * (fontSize / 4)), tSize, , , font, fontSize,

    1. I copied the source code from your article but something is wrong on the last line.

      In the video I see, that after fontSize there is cdrF (or may be something different) ...

    2. Sorry, I correct the mistake. The problem was with me.

      Thanks for article!

  4. You are right, after the fontSize there are few optional parameters for the method 'ActiveLayer.CreateArtisticText'. but them not necessary for the method to work and I have removed them to make code less confusing...(apparently it might be even more confusing).
    The 'cdrF..' is some corelDraw constant, in this case it is' cdrFalse' which is just 'false' value for boolean type and it sets the created text to be not in 'bold font'. You can find many more constants starting with 'cdr...'