Aller au contenu principal

Recherche

Recherche

How To Change Object Properties?

Commentaires

15 commentaires

  • Avatar
    Shotaro Ito
    Hi, Vi.
    Object properties(such as text background) can be modified by Format level VB Script, available from BarTender 9.3, Automation edition or above.(Not supported in Pro/basic edition.)

    You can set VB Script from File > Label Format Options > VB Script.

    OnNewRecords (or OnIdenticalCopies, any event)
    [code]
    'Change object "Text 1"'s background color to Red by various method.
    Format.Objects("Text 1").TextBackgroundColor = BtColor.FromRgb(255,0,0)
    Format.Objects("Text 1").TextBackgroundColor = BtColor.Red
    Format.Objects("Text 1").TextBackgroundColor = BtColor.FromName("Red")
    Format.Objects("Text 1").TextBackgroundColor = Clng("&HFFFF0000") 'AARRGGBB in Hexadecimal. AA(alpha)01-FF treated as non transparent.
    [/code]

    OnPrintEnd
    [code]
    'Revert "Text 1"'s background color to none after print.
    Format.Objects("Text 1").TextBackgroundColor = 0 'No color - transparent.
    [/code]

    [attachment=26:ChangeTextBackColor.png]

    attached sample demonstrates how to change text background color by user input.
    [attachment=24:ChangeTextBackColor.zip]

    For detail, please check [url="http://s3.amazonaws.com/SeagullBarTender/ftp/WhitePapers/WhitePaper_DynamicallyChangingObjectsAtPrint-TimeUsingVBScript.pdf"]White paper: Dynamically Changing Objects at Print Time using VBScript[/url] and [url="http://s3.amazonaws.com/SeagullBarTender/ftp/WhitePapers/WhitePaper_GHSLabeling.pdf"]White paper:GHS Labeling[/url]

    Hope that helps!
    0
  • Avatar
    Legacy Poster
    OnPrintEnd
    [code]
    'Revert "Text 1"'s background color to none after print.
    Format.Objects("Text 1").TextBackgroundColor = 0 'No color - transparent.
    [/code]

    above code does not apply to Box, I get this error: OnPrintJob(Line1):: Operation not supported for this object type
    What's the syntax for a Box?
    0
  • Avatar
    Shotaro Ito
    For Box/oval color you can do like this.
    [code]
    Format.Objects("Box 1").LineColor = BtColor.FromName("Yellow")
    Format.Objects("Box 1").FillColor = BtColor.FromName("Red")
    [/code]
    0
  • Avatar
    Legacy Poster
    Can the same thing be accomplished in International Enterprise Version 8.01? I wish to be able to change the fill color of a box on demand.
    Thanks.
    0
  • Avatar
    Legacy Poster
    [quote name='dbro34' timestamp='1340726262' post='2676']
    Can the same thing be accomplished in International Enterprise Version 8.01? I wish to be able to change the fill color of a box on demand.
    Thanks.
    [/quote]
    dbro34,
    The Object class was added in a later version (9.3, I believe). You'll have to upgrade to this version to change the fill color programmatically.
    0
  • Avatar
    Legacy Poster
    Thanks for the info. Is it possible to pass database info to a variable, say for the RGB like so?

    [code]

    Format.Objects("Box 1").LineColor = BtColor.FromRgb(intR,intG,intB)

    [/code]
    0
  • Avatar
    Shotaro Ito
    Yes you can use database field data.
    BarTender document options > OnNewRecord event,
    [code]
    Format.Objects("Box 1").LineColor = BtColor.FromRgb(Field("RED",0),Field("GREEN",0),Field("BLUE",0))
    [/code]
    Note field RED, GREEN, BLUE can only have integer of 0 to 255.
    0
  • Avatar
    Legacy Poster

    I know that its been a couple of years with this, but can you change the color via say a number range? I.e. RED = 1, BLUE = 2, GREEN = 3. This would mean that if I had the number 123 it would come out as 123?

    0
  • Avatar
    Shotaro Ito

    It's me happened to find your post in too late.. No, there's no good way doing that via VB Script. Try HTML text object instead.

    0
  • Avatar
    Legacy Poster

    Good morning,

     

    I resent a topic I wrote in the wrong section (sorry for that !) :

     

    I have the text of my labels in bartender from an Office Access 2007 data base.

    In one field, I have the color in wich one I would like to print the text with baretender.

    How can I do to use this field in bartender in order to print the text in the correct color. The color can change at each label.

     

    I tried to write a VB script in the properties of the filed but I have a script error.

     

    I wrote this :

     

    Set Texte = Objects(Field("Etiquettes.Nom_produit"))
    If (Field("Etiquettes.Couleur")) = “Red”) Then
          Texte.TextColor = btColor.Red
    Else
          Texte.TextColor = btColor.Green
    End If

     

    Thanks for your help.

    0
  • Avatar
    Legacy Poster

    Well, I got information about this point that I would like to share :

     

    1 - VBscript in the field properties doesn't allow to change de text color.

    2 - Only VBscript in the general properties of the document allows to change the text color in a field, but only for the entire field, not for each field (in the case you make a concatenation of different fields.

     

    Hope this will save time to someone !

    0
  • Avatar
    Legacy Poster

    So after trying to change the color fill of a box based on a field using Pro 2016 and being unsuccessful, I found this post. Just to clarify, VBScript implementation in BT is dependent upon version (10, 2016) and application level (Pro, Automation). Is this true? And changing a shape object can't be done in Pro? Is there a document that covers this in detail so we know what we can use and what we can't use?

    0
  • Avatar
    Shotaro Ito

    Professional edition doesn't support events in Document options VB Script - which enables modifying object properties such as color.

    That's available in Automation edition or above.

    (Accessible from File > BarTender Document options > VB Script tab)

    That's only VB Scripting difference over editions.

     

    Edition difference in VB script is shown as

    "Data Processing: Visual Basic scripting for document open, close, save, and print-time events"

    in Compare BarTender editions.

    http://www.seagullscientific.com/label-software/barcode-label-design-and-printing/compare-bartender-editions/

    (However I can hardly say that above is very clear.)

     

    There's no major functionality change in VB script since 9.3 to 2016. 

    0
  • Avatar
    Jacob Smith

    None of the URL's referenced are valid.

    0
  • Avatar
    Peter Thane

    The original link(s) is from a post from 10 years ago relating to a BarTender version that has been superseded a number of times over which is probably why that White Paper is no longer accessible. 

    From the later posts such as those in June 2016 the Document Options VB tab is now the way you need to go to change the format of the fields themselves such as the text colour. 

    This more recent document discusses some of the VB options etc and maybe useful https://www.seagullscientific.com/media/1431/bartender-intelligent-templates-201608.pdf

    (It looks to me like the link above is completely messed up and not sure why there is a reference to GHS labels but for some info about this try https://support.seagullscientific.com/hc/en-us/articles/216385497-Creating-a-GHS-compliant-label-Video-7-51-)

    0

Vous devez vous connecter pour laisser un commentaire.