Product: LABELVIEW, CODESOFT
Version: LABELVIEW Gold 2014 and Newer, CODESOFT Enterprise 2014 and Newer
Use the following procedure to automatically print multiple labels in sequence using Visual Basic Script (VBScript). This example demonstrates how to print one label, then automatically print additional labels to different printers after the first print job completes.
| 1. Open the starting label that will initiate the print sequence. |
| 2. Right-click an empty area of the label and select Properties. |
| 3. Select Visual Basic Scripting. |
| 4. Enable Activate the call of events. |
| 5. From the event drop-down list, select Sub OnAfterPrintJob(ByVal Doc). |
| 6. Enter the VBScript shown below, or use the vbscript.txt file included with this article. |
Note: Update the label file paths so they match the locations of your label files on your computer.
| 7. Click OK to save the VBScript. After the first label is printed, the script will automatically print Next.lab (or the labels specified in your script) to the configured printer. |
| 8. Verify that the option Load Printer saved in the document is enabled. |
Example VBScript
dim nextLabel, nextlabel1, labelpath, labelpath1
labelpath = "C:\label.lab"
labelpath1 = "C:\label2.lab"
set nextlabel = Application.Document.Open(labelpath, true)
nextlabel.PrintDocument(1)
nextlabel.FormFeed()
nextlabel.Close()
set nextlabel1 = Application.Document.Open(labelpath1, true)
nextlabel1.PrintDocument(1)
nextlabel1.FormFeed()
nextlabel1.Close()
Result
When the initial label finishes printing, the OnAfterPrintJob event runs the VBScript, opens the additional label files specified in the script, prints them, advances the media, and closes each document automatically.
