Zum Hauptinhalt gehen

Suche

Suche

Show Hide Picture Using Vb Script

Kommentare

2 Kommentare

  • Avatar
    Shotaro Ito
    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.
    MultiLine
    [code]
    If (Field(1)="") THEN
    Value=""
    ELSE
    Value="PIC.png"
    END IF
    [/code]
    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="http://s3.amazonaws.com/SeagullBarTender/ftp/WhitePapers/WhitePaper_DynamicallyChangingObjectsAtPrint-TimeUsingVBScript.pdf"]Dynamically Changing Objects at Print-Time using VB Script[/url].
    0
  • Avatar
    Chris Oxford

    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

    Else

        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
    Else
       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.

     


       

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.