Adding A Bmp Or Jpg Picture Conditionally
I am reading a database file (excel) using Bartender Automation 9.4. The database table has a column that indicates if the item is certified or not. The cell contains either yes or no. If yes, I want to print the cert logo on the label. If no, change the properties to not print the logo. The logo is in a graphic folder but it will never change. I want that static logo to print not to print based on the content of the cell on the item being printed from the database. I saw a similar request in the forum based using check boxes and radio buttons but couldn't figure out how to tie the database field to the image I want to control. Is what I'm asking to do possible with my version of bartender?
0
-
The way I did something similar to this was I used a prefix and suffix to build the path and extension for the image around the database result. My database result returns either a partial logo name or "BLANK" ... I have a prefix of "\\server\share\path\L3" and a suffix of ".png" ... I then used that as my image path.
So ...
When I want the image to print, the database passes in "LOGO" and the image "\\server\share\path\L3LOGO.png" is printed on the label.
When I want no image to print, the database passes in "BLANK" and the image "\\server\share\path\L3BLANK.png" is printed on the label. L3BLANK.PNG is a 1 pixel white image, so the end result is nothing visible prints.
I think something similar would do what you're looking for (maybe having a "YES.jpg" and "NO.jpg" image or something). Hopefully it helps.0 -
You can use a VB script that uses the code, assuming your picture name is picture 1, and your certified yes/no value is saved as "certified"
[code]if (certified = "yes") then
Format.Objects("Picture 4").DoNotPrint = false
else
Format.Objects("Picture 4").DoNotPrint = true
end if[/code]0 -
Thanks for the code but I'm a little confused.
if (certified = "yes") then
Format.Objects("Picture 4").DoNotPrint = false
else
Format.Objects("Picture 4").DoNotPrint = true
end if
In the above is that just a typo or am I missing something. You first said "assuming your picture name is picture 1" then Picture 4 is in the code?
Using the above template I entered:
if (Field("MLPins$.Kosher Qualified") = "yes") then
Format.Objects("Picture 1").DoNotPrint = false
else
Format.Objects("Picture 1").DoNotPrint = true
end If
I get an error when I press OK after modifying the code.
<Line 4: : Object property is not supported. This property is allowed only when running document event scripts.>
I don't understand the error.
MLPins$.Kosher Qualified is the cell that contains "yes" or blank in the database.
I have the logo picture type as "Data Sourced Picture:
Source is "Path" and the path is: C:\Do not back up\Zebra Labels EP\pcx\Kosher-Dairy.bmp
The data source is VB script and the general tab shows the object name as "Picture 1".
I like this codes approach and seems like it should work if I can get the ducks lined up right.
Suggestions.0 -
Not sure I understand what you did? Would the actual name of the logo to use be in the database rather than a yes or no indication that a logo was to be printed? 0 -
I'm very sorry. Yes, it should be "Picture 1". I was copying some code I use elsewhere and forgot to change it from 4 to 1.
As for your error message, It looks like you need to place this code in a document event control script. You can get to these in your file by going [i]File > Label Document Options[/i] and clicking the VB tab. (This would be under [i]Label Format Options[/i] in version 9.4-). From there, you can put the code from earlier in one of the event scripts. I would recommend putting it under the OnNewRecord script.
Hope you can follow all that.0
Please sign in to leave a comment.
Comments
5 comments