Show Hide Picture Using Vb Script Follow

Legacy Poster


How to Hide picture when label object has a value using vb script. Currently, we created two bartender file one with picture and other one with no picture. And its time consuming where we need too choose one of the two.


If (Field(1)="") THEN
>> Hide Picture
>>Do nothing

Please help.

Thanks In Regards


Shotaro Ito
Comment actions Permalink

You can datasource picture's path (file name), so when show picture, set image file's file name in datasource, when hide picture, set empty string in datasource.
In default path, specify the folder which contains pictures. (if empty, bartender look for the same folder as .btw document.)
The datasource can be specified by Database field, or VB Script like below.
If (Field(1)="") THEN
Note set error handling to "Never abort print job", to avoid picture file not found error.

Another idea is Use BarTender Document option's script - From there, you can change object visibility from PrintVisibility Property.
That's available from BarTender 9.3 or later, Automation edition or above. for detail, see White paper: [url=""]Dynamically Changing Objects at Print-Time using VB Script[/url].
Chris Oxford
Comment actions Permalink

We finally figured this out. Been trying to for years. Credit to our engineering intern who's been looking at this for months.

In View-->View Options--> VB Scripting tab, under OnNewRecord, use the following code:


If Field(1).Value = "Y" Then
    Format.Objects("Picture").PrintVisibility = True


    Format.Objects("Picture").PrintVisibility = False

End If

Where Y is whatever condition you want image to print, and "Picture" is the object name of the picture (set in General Tab of Picture's Properties). Or reverse the logic if you need to.

Have not tried this with using an empty data cell as a False trigger, may have to figure out if you need to use "Empty" "Null" "" or "0" depending on how your database sends empty data. Sometimes we put one [space] in data fields that would otherwise be empty, just to save an error. We also in the past fed Bartender a none.bmp or non.jpg image file, which is an image with one white pixel saved in the same location as the picture file. This avoided the error where a picture could not be found.

You can set multiple objects visibility based on different conditions. We actually need to turn off and on several different text objects and a picture, depending on part number. When we have one outlier, we do it like this:


If XXXXX.Value = "Condition1" Then
    Format.Objects("Picture1").PrintVisibility = False
    Format.Objects("TextObject1").PrintVisibility = False
    Format.Objects("TextObject2").PrintVisibility = True
    Format.Objects("TextObject3").PrintVisibility = True
   Format.Objects("Picture1").PrintVisibility = True
    Format.Objects("TextObject1").PrintVisibility = True
    Format.Objects("TextObject2").PrintVisibility = False
    Format.Objects("TextObject3").PrintVisibility = False
End If

We also sometimes use a dedicated column that just has Image visibilty, either Y or N.

This saves us having to clog up network traffic to load a .jpg every time we need to print a label. We print thousands of PN labels a day, so if we need to load a .jpg or even a .bmp, the network can bog occaisionally.



Please sign in to leave a comment.