CorelDraw & VBA
Summary & Introduction
Guide to CorelDraw VBA
Creating Variable Data
Variable Data From Access
Variable Data From Excel
Variable Data Without a Data File
CorelDraw BarCode Wizard
EAN13 BarCodes Without The Wizard
Code 39 BarCodes Without The Wizard
ITF-14 BarCodes Without The Wizard
Code 128 BarCodes Without The Wizard
QR BarCodes
Variable Pictures
Sorting for Guillotining
Repositioning Data
Pantone Colors
Saving VBA Code to a Previous Version of CorelDraw
PhotoPaint
Miscellaneous VBA
Help
 
Summary


This web site is to enable people to automate CorelDraw & PhotoPaint using VBA. I have spent far too many hours determining how Corel VBA code works.
I do not want anyone else wasting time on procedures I have solved.

All code on this site is for free and nothing is pass-worded. If you want help with your project I am happy to help.
However I can also supply a finished project for a fee.

The website was originally started in early 2009 and was called corel-vba.awardspace.com
It was moved to agilityhoster.com several years ago.
Please note that I have changed my email address since lycos no longer offer free email.

Over the years I have had some interest from the engraving industry who have required automation of repetitive tasks.

The power of VBA is amazing. With it you can get data from most files and directly from web pages.
You can change file names, move files, create directories, have control of other VBA programs such as Excel, Word, Access, Outlook, Powerpoint, Publisher and AutoCAD such that they can talk to each other.
Even non-VBA programs can be controlled to some extent.

This web site was originally created to enable CorelDraw users to use VBA to create documents that contain variable data including Barcodes such as EAN13, Code 39, variable graphics and variable colors using sources of data such as text, Excel and Access files.
Methods to reposition data, sort for guillotining and color control are provided. It still does this, but this web site's purpose has expanded.

For those with no experience of VBA this site will provide a steep learning curve.
Under the heading "Guide to CorelDraw VBA" is a sub heading "VBA Introduction", should this be too challenging I suggest you start is with VBA for Excel.
There are plenty of Excel VBA sites where they teach you how to begin to use VBA. From there come back here for specific CorelDraw programming.

For those with some VBA experience in "Guide to CorelDraw VBA", I have guides how to Opening Other Applications, Event Handling, the use of CQL in Coreldraw and Security.

Some VBA code for Photo-Paint is provided.

There are also some useful VBA code in Miscellaneous VBA. Particularly look at "Selecting Folders or Files", the use of ProgressMeters and I have just added a CorelDraw Date Picker.

To disseminate the VBA knowledge I have gained over the years I have created a new website, VBA Tips, that deals with VBA and other applications, other than CorelDraw.
At the moment it covers only Adobe Acrobat and only in a small way. It is currently in development.
In in time it will provide code to link to other applications such as SQLite databases, the Command Prompt etc.

Introduction


There is very little help on the internet to use VBA with CorelDraw. My aim is to provide some help in this matter.

Right out front. I am not a graphic artist. I intend the site to be useful to those who wish to automate CorelDraw.

I mainly use CorelDraw with VBA to produce variable data documents. I link Excel to CorelDraw to produce sheets with variable numbers, strings and Bar Codes.
It is a straight forward task to use VBA to vary the background color of a page, a font or change a font. I have automated PhotoPaint to color correct photos.

A customer of mine regularly supplies a Publisher file to use as a template to print variable data. We have abandoned the use of Publisher to print variable data.
It has poor control and has caused us to reprint a job. We recreate the static graphics and inserted it as the Master Layer in CorelDraw & then I added the variable data using VBA.

My intention is to make public the methods I use to print variable data.
There are many companies that offer packages that will allow you to add variable data and they can cost up to several thousand dollars, but it is not that hard to write your own based on VBA.
You can vary the text, fonts, font colors, background colors & the pictures.

Variable Bar Codes are a problem. Corel does not seem to want to add VBA control of barcodes.

Print Merge is not that user friendly & has limitations.

I prefer to use VBA instead of print (mail) merge because of its control. You cannot accidentally create multiple merge locations on the same sheet without knowing it.
Unfortunately you must rely on SendKeys to automate the BarCode Wizard. I need at least an API to control the BarCode Wizard. How long do Corel need? Where is their VBA support for the BarCode Wizard?

I currently use CorelDraw X6 but have access to CorelDraw 11, 12 and CorelDraw X3.

On this site I provide modules to sort data alphabetically & sort for guillotining so the cards are vertically above each other so that when they are guillotined they are in sort order.
I provide modules as starting points to further modify for each particular data-merging problem. My current files read data from an Excel file and an Access database.
In the future I may include a MySQL database & perhaps a text file. My expertise is in Excel & Access & have some knowledge of MySQL & VBA in Word.

Most of my time preparing files for this web site has been 5% to write the code & 95% of my time adding comments, options to give you an idea as to how to alter the procedure to your problem & adding user friendly dialog boxes etc.
It has been a worth while exercise as it has honed by skills & I have discovered better ways of doing things.

Every few months, for a customer, I create a bar coded file for printing. It unfortunately I have to use Sendkeys.
Why won't Corel provide an API of BarCode Wizard? It would set them apart from their opposition.
In the job I do, the bar code requires a colored background not a white background.
BarCode Wizard does not allow non-white backgrounds on barcodes unless the barcode is converted to a eps or metafile etc and then modified.
The way I get around this is to pre-print the backgrounds & then over-print the barcode on the background. I will be providing the method to add variable bar codes.
Whilst preparing this web site I have learnt that if I use CorelDraw 13 I can automatically create eps images of the barcodes & then delete the white background. I have not done this yet but I intend to.

I have no problem creating the variable bar codes and other variable data, but when it comes to publishing these methods I realise that my modules rely on knowledge of the program that only I understand, and so I have to alter them to make it user friendly. Also they may not run correctly if used on computers of other speeds. The bar code procedures will be supplied. Nothing will be hidden.

Keep in mind that multiple page documents with a lot of data even if they contain little or no graphics can be very big before saving.
I recently experienced a memory limitation using CorelDraw with a large variable data file.
Whilst generating 200 SRA3 size pages each containing 250 variable number sets and no graphics the file required a little over 3Gb of memory.
On my 32 bit system with a nominal 4Gb of RAM CorelDraw ran out of memory and was unable to save the file. I was forced to create the job as two files.
The saved size of the two files added together was only 3Mb. A 64 bit system with more RAM would have probably solved this.
Also even with simple variable data jobs keep each file below 400 pages as your computer will slow considerably whilst generating the file.
To minimise the number of pages create separate CorelDraw files to cover the range of variable data.

Be careful when printing from CorelDraw that contains many pages.
When you select Print and the print dialog box appears make sure that the PreFlight check, it the last tab on the right, has completed its analysis before you do anything more.
Otherwise CorelDraw may crash. Even after going into Printer Preferences, again wait until the PreFlight check has updated.


Sites that I have found useful are;

Apart from Alex Vakulenko's old site OberonPlace at http://www.oberonplace.com there is not much else on Corel VBA on the internet. I understand Alex no longer is associated with CorelDraw but works for Google instead.

Judy Hudgins has a site within which there is a section on Corel Draw at "http://www.judyhudgins.com/PAP.htm". There is an interesting sub-section titled "Macros - Introduction".

"CorelDRAW :: VBA macros :: wOxxOm" at http://recentfiles.netfirms.com/

"Macros & Add-ins for CorelDraw Graphics Suite" at http://www.corelvba.com/ has some free VBA code that is not password protected so you can see someone else's code to see how they lay it out and get valuable tips. You must place the .gms file in a GMS folder such as "C:\Program Files\Corel\CorelDRAW Graphics Suite X4\Draw\GMS" then open CorelDraw and read the .gms file in the VBA IDE.

Pearson Software Consulting mainly for Excel VBA tips but some can be applied to CorelDraw VBA.

Stephen Bullen's site. This guy is brilliant! It is mainly Excel orientated. He often uses other languages within VBA to access windows components.
I have created a toolbar button in Access that toggles the case of selected text. It uses Stephen's code.

The Word MVP Site for Microsoft Word on the internet.

Susan J. Dorey in her section Tools. Is very good for Word & Access VBA, particularly Word. There is not much on Word VBA on the internet.

Karl Heinz Kremer's site showing how to control Acrobat using VBA is a good starting point if you have this need.  

My email address is corel-vba@mail.com.

2021_10_02