For CorelDRAW versions 6 through 9, the only method of automating tasks was using the Corel SCRIPT language. Solution developers used Corel SCRIPT to create intelligent mini-applications for drawing shapes, repositioning and resizing shapes, opening and closing documents, and setting styles within CorelDRAW.
Although the Corel SCRIPT language was useful for automating basic tasks, a more flexible and powerful solution became necessary. For version 10, CorelDRAW was enhanced with support for the Microsoft Visual Basic for Applications (VBA) engine, which handled behind-the-scenes automation. The addition of VBA made CorelDRAW immediately accessible to millions of VBA and Microsoft Visual Basic (VB) developers around the world. Since then, VBA has been supported by every version of the CorelDRAW software suite.
The software suite also supports Microsoft Visual Studio Tools for Applications (VSTA), the successor to VBA.
Support for JavaScript was added to the suite in version 2019.
JavaScript is supported in CorelDRAW and Corel PHOTO-PAINT, on both Windows and the macOS.
VBA and VSTA are supported in Corel DESIGNER and the Windows versions of CorelDRAW and Corel PHOTO-PAINT.
In the Windows version of Corel PHOTO-PAINT, you can automate tasks by using VBA or VSTA to create a macro, or by using Corel SCRIPT to create a script. A macro is the better choice if you want to write the code that is required to carry out the task (by using VBA or VSTA), while a script is the better choice if you want to record the steps that are required to carry out the task (by using Corel SCRIPT). For information on using Corel SCRIPT with Corel PHOTO-PAINT, see "Corel scripts" in the main Help file for Corel PHOTO-PAINT (Help > Product Help).
By supporting JavaScript, VBA, and VSTA, the software suite offers a platform for the following:
VBA and VSTA each provide their own fully integrated development environment (IDE), with contextual pop-up lists, syntax highlighting, line-by-line debugging, and visual designer windows. These features are particularly helpful to inexperienced developers.
For more information on JavaScript, VBA, and VSTA, see the following topics:
JavaScript (JS) is a dynamic, prototype-based scripting language that supports object-oriented and functional programming styles. Popular as a scripting language for Web pages, JavaScript can also be used in non-browser environments, such as CorelDRAW Graphics Suite and CorelDRAW Technical Suite to automate repetitive tasks.
The software supports ECMAScript 6, the update to JavaScript, and all of its objects, libraries and functions, except for browser-related components. For more information about using JavaScript, see “Working with JavaScript (JS) scripts”.
Microsoft Visual Basic for Applications (VBA) is a built-in programming environment that can be used to automate repetitive functions and create intelligent solutions in the software that supports it. VBA is a subset of the Microsoft Visual Basic (VB) object-driven programming environment. Usually, VBA is integrated into another application to customize functionality within that application.
VBA is both a language and an editor. The VBA language cannot be used without its editor, and the VBA editor is the only utility in which VBA code can be edited or VBA programs can be run.
The VBA language is an event-driven programming language. In other words, it is used to write code that produces a response to an action, such as clicking a button or choosing an option from a list box. When the action occurs, the appropriate event is called, and the code for that event is executed. Events can be simple or complex. For instance, you can code a single line that displays a message box or write an entire procedure that interacts with a database.
With traditional procedural programming (or "object-driven programming"), the program starts at the first line and executes one line at a time. VB provides an example of an object-driven programming environment.
Most of the code examples provided in this documentation are written in VBA.
The VBA editor — called the "Scripts Editor" (formerly the "Visual Basic Editor") in Corel DESIGNER, CorelDRAW, and Corel PHOTO-PAINT — is an integrated development environment (IDE) that lets you manipulate the objects that are exposed by the object model of the application. To help you code macros, the Macro Editor provides context-sensitive Help for all the object-model elements that are available to you.
VBA is an in-process automation controller. In other words, VBA can be used to control software features that can be automated, and VBA runs efficiently by bypassing the interprocess synchronization mechanisms. However, the automation that the in-process VBA can access can also be accessed by the following:
VBA provides a set of tools for customizing the graphical user interface of the software. These tools let you process and present data efficiently and effectively. Advantages of using VBA include the following:
VBA lets you customize an application to suit your needs, or even integrate it with another VBA-enabled application by referencing the object-model components of the second application. Although VBA was developed by Microsoft and is built into almost all its desktop applications (including Microsoft Office), Microsoft licenses the technology to other companies (including Corel Corporation; Autodesk, Inc., in AutoCAD; and IntelliCAD Technology Consortium, in IntelliCAD). Software products that support VBA can typically be used to control each other, and they can even be used to control some software products that do not support VBA. Consequently, you can use VBA to build solutions in Corel DESIGNER, CorelDRAW, and Corel PHOTO-PAINT that access a wide variety of other software products: databases, word processors, XML editors, and more.
For a complete list of applications that support VBA, see the Microsoft website.
How does VBA differ from VB and VBScript?
The VB programming system is an advanced set of programming tools that provides advanced functionality and components for the Windows operating system and other Windows-based programs. For example, unlike VBA or VBScript, VB lets you create application extensions (DLL files) and stand-alone executable programs (EXE files). (The programs that you create with VBA must run inside the host application.)
VB is a "visual" version of the BASIC programming language — that is, it provides visual cues within the editor. As a result, VB is an easy language to learn. In addition, Microsoft has greatly enhanced the original BASIC language, so that VB is both powerful and fast (although not as powerful as Java or C++, nor as fast as C).
VBA is a subset of the VB programming language, and it uses the programming structure of VB to manipulate the object-model elements that are exposed by an application. The manipulation of these objects results in small packets of code procedures within the application. These code procedures and resulting projects are called "add-ins."
VBScript (sometimes referred to as Microsoft Visual Basic, Scripting Edition) is also a subset of the VB programming language. VBScript is a Web-based HTML document scripting language.
How does VBA differ from JavaScript?
VBA is similar to JavaScript in that it is a high-level, procedural programming language with very little memory-pointer support. (For more information, see Allocating memory.) In addition, code that is developed in VBA, much like code developed in JavaScript, supports on-demand compilation and can be executed without being compiled.
VBA is also similar to JavaScript in that it cannot be executed as a stand‑alone application. JavaScript is embedded within the suite for manipulating the document object model (DOM) of the main applications. Likewise, VBA programs are executed inside a host environment (such as Corel DESIGNER, CorelDRAW, or Corel PHOTO-PAINT) to manipulate the object model of the host.
Finally, whereas VBA uses a single equals sign ( = ) for both comparison and assignment, JavaScript uses a single equals sign ( = ) for assignment and two equals signs ( == ) for Boolean comparison. (For more information, see Using Boolean comparison and assignment.)
How does VBA differ from C and C++?
Like C and C++, VB uses functions. In VB, functions can be used to return a value, but subroutines cannot be used in that way. However, functions are used in C and C++, regardless of whether you want to return a value. (For more information, see Using functions and subroutines.)
VBA allocates and frees memory transparently. In C and C++, however, the developer is responsible for most memory management. As a result, using strings in VBA is even simpler than using the CString class in C++.
Finally, whereas VBA uses a single equals sign ( = ) for both comparison and assignment, C and C++ use a single equals sign ( = ) for assignment and two equals signs ( == ) for Boolean comparison. (For more information, see Using Boolean comparison and assignment.)
How does VBA differ from WSH?
Windows Script Host (WSH) is an out-of-process automation controller that lets you do occasional scripting and automation of Windows tasks and can be used to control software. Although WSH is a useful addition to the Windows operating system, WSH scripts tend to be slow because they must run out of process, and they cannot be compiled (and must be interpreted as they are executed).
WSH is a host for a number of scripting languages, each of which has its own syntax. However, the standard language that WSH uses is a macro language that resembles VB, so for standard scripts, the syntax is the same as in VBA.
The successor to VBA, Microsoft Visual Studio Tools for Applications (VSTA) is based on Microsoft Visual Studio 2017. In Corel DESIGNER, CorelDRAW, and Corel PHOTO-PAINT, the VSTA feature supports the .NET framework and enables development in two programming languages: Visual Basic .NET and Visual C#.
The VSTA Editor in Corel DESIGNER, CorelDRAW, and Corel PHOTO-PAINT is an integrated development environment (IDE) that lets you create VSTA solutions for the software.
To use the VSTA macro features with Corel DESIGNER, CorelDRAW, and Corel PHOTO-PAINT, you must have Microsoft Visual Studio 2017, Professional, Ultimate or Premium installed.
If you install Microsoft Visual Studio after installing CorelDRAW Graphics Suite or CorelDRAW Technical Suite, you must re-install the VSTA macro features by modifying your CorelDRAW Graphics Suite or CorelDRAW Technical Suite installation.
How does VSTA compare with VBA?
Both VSTA and VBA allow you to create powerful macro solutions. With VSTA, you use the VSTA Editor as an IDE, and you use Visual Basic .NET or Visual C# as a programming language. With VBA, you use the Macro Editor as an IDE, and you use VBA as a programming language.
If you want to perform any of the following tasks, you can use either VSTA or VBA:
However, if you want to perform any of the following tasks, you must use VSTA: