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
Trim Marks
PhotoPaint
Miscellaneous VBA
Help
 
Sorting for Guillotining

If you are going to guillotine the finished sheets you probably want each successive data item below the preceding item. Here is a graphical representation of 6 sheets with data arranged 4 x 3 on each sheet.

Sorted.jpg

On the first sheet data item 1 is printed first followed by data item 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67 as shown above as the pink sheet.

The the second sheet shown, as in purple, data item 2 is printed first, then 8, 14, 20, 26, 32, 38, 44, 50, 56, 62 and finally to fill the second sheet 68.

The 12 stacks when cut be placed on top of each other and the data is in order.

There are three ways to sort the data.

1.     Sort the data into a new sorted data file.

Pre-sorting the data into a new database or file seems the most logical but has the disadvantage that you cannot add additional data without creating a new database or sorted data file again. It is also unnecessary but is the safest because you can check the data. Excel is usually used for this. Here is the example shown in the diagram above using this bas file inserted into Excel.

Excel_Sort_1.jpg Excel_Sort_2.jpg
Here on the left is the original data that goes from 1 to 72.. Here on the right is the data with the sort order in the first column that was generated with the bas module file.
Excel_Sort_3.jpg

This view shows the Excel's Data Sort Dialog box. Here you sort against the column containing the sort order. In this case it is Column A. I have not added a header unlike the adjacent column whose header is VALUES.

Excel_Sort_4.jpg

Here the data has been sorted according to the sort order column. The sort order column can now be deleted. Notice that the the first 12 items are the same as the top 12 numbers in the diagram at the top of this page. Also the 13th number is 2. It will be printed on the sheet underneath the top sheet directly under the number 1.



2.     Sort the data into a new sorted array.

First read the data from its source into a vba array and from this create a new sorted array. This is faster than creating a new data file or rearranging in Excel. It is slower than sorting the data on the fly. There is usually no display of this data before printing. It is usually difficult to check that the data has been sorted correctly until it is printed. Here is a macro that will help you sort the data before printing. It is based on the same method as the bas file in the method above. This bas file can be imported into any application that supports VBA such as Excel, Word, Access or CorelDraw to run.

3.     Read the data, on the fly, in a sorted order, from the original unsorted array.

This eliminates the step of writing to a new array and then later reading from this new array. Sorting on the fly selects the correct data as it writes each page. Here is a macro to determine the location in the source data for the data on a page. The bas file needs to be imported into VBA in a CorelDraw file although it will also run in other VBA compatible applications such as Excel, Word or Access.


Warning: It is advisable to fill all blank data fields with data. If not, then unless you write the procedure carefully the procedure may halt at the first blank data field. i.e. If you are printing to 6 pages with 12 data items per page, as in the diagram above, then make sure you have 72 data items. If you only have 67 data items the procedure could halt on page 2 since the first blank data item, 68, is on page 2. The additional data should be such that it satisfies the procedure and if necessary will create a barcode or is a file address for a graphic but is easily identified after printing, so the dummy cards can be discarded.


2015_08_06