Dynamically Changing Objects at Print Time Using VB Script PDF
Dynamically Changing Objects at Print Time Using VB Script PDF
White Paper
Dynamically Changing
Objects at Print Time
using VB Script
Using BarTenders Document-Level
Scripts to Change Text, Barcode,
and other Objects at Print-Time
Contents
Overview ............................................................................................ 3
Page 2
White Paper: Dynamically Changing Objects at Print Time using VB Script
Overview
Object Automation
Position
Color
Size
Visibility
Font
For full documentation on all object properties, see the Automating BarTender
section in the BarTender online help system.
Page 3
White Paper: Dynamically Changing Objects at Print Time using VB Script
OnOpen
Executed when the document is opened.
OnClose
Executed when the document is closed.
OnSave
Executed when the document is saved.
OnPrintJobStart
Executed when the document is begins printing.
OnNewRecord
Executed during printing, each time a new record is read from the database.
This is the event that will most often be used to change objects during the
middle of a print job.
OnSerialize
Executed during printing, each time there is an opportunity for a serial number
to change.
OnIdenticalCopy
Executed during printing, each before every label that is printed, even
identical copies.
OnPrintJobEnd
Executed when the printing of the document ends normally.
OnPrintJobCancel
Executed when the printing of the document is canceled.
A common use case for this feature would be to change objects in response to the
data coming from a database. In this case you would write a script for the
OnNewRecord event. You could change the color of a text object, depending on
whether or not a warning condition was indicated. For example, you could write the
following script for the OnNewRecordEvent.
Page 4
White Paper: Dynamically Changing Objects at Print Time using VB Script
If you wanted to have a field in your database contain the name of a color like red
or yellow, you could use the code below to set the color of an object.
You can hide or show objects based the data that is printed. You can either use an
objects Visible property, or you can simply move it on or off of the design area,
using its X and Y properties. For example:
Then the Condition Color field in your database could contain values like
BtColor.FromRGB(255,0,0) or BtColor.Red.
Sample Document
The GHS_Demo.btw file that is installed with BarTender is a good example of a VB
Script that changes objects size, color, and moves them on and off of the design
area to control visibility.
Page 5
Available Seagull White Papers
Companion Applications
Printer Maestro: True Enterprise Print Management for Windows
Librarian
BarTender Security Center
BarTender Web Print Server
Recent Upgrades
Whats New in the Latest BarTender