Hide a Label Object (Picture, Text, Barcode, etc.) – CODESOFT Instructional Article
Summary
A typical scenario for this is when you have an element on a label that needed to be printed only when certain conditions are met. This Instruction Article explains how to programmatically hide or unhide an element in a CODESOFT label.
Instruction
There are 2 methods of removing (prevent from printing) an element from a label:
- Clear the Data Source
- Visual Basic Script to Toggle the “Printable” Property of the Object
#1 Clear the Data Source
The first method is to clear the content of the element. If it is a text or barcode field, you can simply change the content to blank. However, if the element you want to hide is a picture, thing gets a little bit more difficult.
If you dynamically pull the picture from a file, changing the filename or blank out the filename will do the trick. (see Mustang example in the attached label file). If the picture is embedded into the label, we will have to use the second method.
#2 Visual Basic Script to Toggle the “Printable” Property of the Object
The second method is to use Visual Basic Script to toggle the ‘printable’ property of the element. This solution will, in fact, work for every element type in the label.
Example:

The above label has 4 elements:
| Elements | Purpose |
| Check-Flag | Formula that does all the magic |
| Flag | Data entry field. Use to toggle the elements on/off |
| Mustang | Dynamic graphic element (picture load from a file). The value comes from Check-Flag |
| Truck | Static graphic element |
In Check-Flag, we use a simple formula to set the filename for Mustang:
If (Flag = 1), “Mustang”, “”)
The formula will return the word “Mustang” if Flag has value of 1, otherwise, it will return “” (blank). A blank filename will effectively make the picture disappear from the label.

Most people will stop right here at the formula. The other component of the formula property is Visual Basic Scripting. In this situation, we use it to make the Truck appear or disappear.
The script we use is similar to the one in the formula section. Instead of setting the filename, we are changing the “Printable” property of the label element.
if document.variables.Item("flag").Value() = 1 then
document.DocObjects("truck").printable = false
else
document.DocObjects("truck").printable = true
end if
The logic is very simple, if Flag = 1then set the Printable for Truck to false, otherwise, set it to True.
The difficulties for this method is to figure out how to address the individual property (Printable) on the label file. The example above shows you how. You can use this concept to manipulate other element’s properties.
Outside Sources and Helpful Links
CODESOFT has a somewhat helpful programmer manual that you can use as reference. It can be found under Help menu.

Additional Comments
Label Sample File
Author
Related Articles
- Loftware Redirect Print to PDF action using multiple printer seats
- License is failed – TEKLYNX CENTRAL Error Message
- Loftware Web Designer vs Desktop Designer
- Loftware Workday API Splitting Print Jobs
- Planning a BarTender Server Migration and Upgrade – BarTender Instructions Article
- Deciding on an In-Place Upgrade, Test Server, or Migration – BarTender Reference Article