CorelDraw & VBA
Back to the Main Menu
VBA Introduction
Artistic Text
Paragraph Text
Finding & Changing Text
Opening Other Applications
User Interface
Event Programming
Storing User Data
Error Handling
Speeding Up CorelDraw
VBA Security
Guide to CorelDraw VBA

User Interface

There are 4 ways a user can interact with a macro.
Dialog Boxes, MsgBoxes, Forms and Event Programming.
I have given Event Programming a section elsewhere on its own.

Dialog Boxes

There are several types of Dialog Boxes.
Input boxes are used so that the user can enter text.
Dialog boxes are used where the user selects properties such the color.

An Input Box is a dialog box that has 1 field into which the user can insert a string (text).

The syntax of InputBox is as follows. The Inputbox returns what ever the user has typed as a string.
InputBox(Prompt, [Title], [Default], [XPos], [YPos], [HelpFile, Context]) As String

The Prompt is where you ask the user for a particular type of data.
eg. "How many columns do you want?"

The Title is the dialog box heading and the default is CorelDraw.

The default is the string that appears in the input field when the InputBox first opens.
The user can type something else, leave the default string or delete the default and leave the input field blank..

The XPos and YPos sets the position of the InputBox on the screen as measured from the top left corner of the screen.
The default position is in the centre of the screen.
The unit of measure is a Twip where there are 1440 Twips per inch.
There are approximately 56.69 Twips per mm.
Determining the screen width is a lot more difficult. You can use GetSystemMetrics but I will not explain how here.
I suggest not specifying a position and the InputBox will be in the centre of the screen.

I have not used a HelpFile or its Context.

Message Boxes

These are used to alert the user to something and the user can have a choice as to continue or stop.

Msgbox has the following syntax.
Msgbox(Message, [Button Style], [Title], [Help File, Context])

The square brackets [ ] indicate that that between is optionally required.
If a Help File, a chm file, is specified a Context must also be specified such as 0.
Don't bother with a Help file. It is rarely used.

In the Msgbox Message section, which is the section before the first comma, text is indicated by enclosing in quotation marks.
The use of an ampersand (&) outside quotation marks can add more text again.
Msgbox is very tolerant so you can include numbers without quotation marks and it will treat your number as a string (text).
Also the Message can be a variable that represents a string or a number.

The Button Style if not specified uses the default style which is only 1 button "OK".
Although named Button Style this can also add icons to the Message box.
You cannot add your own icon but can use 1 of 4 VBA icons.

Next is the Title of the message box that appears at the top of the message box.
If you do not specify a Title the the default title is the application name which in this case is CorelDraw.


These are created by the user as an interface to start, stop, open Dialog Boxes, enter text and select properties for a macro.

Issued 2016_12_08