Print/hide Objects Via Data Entry Checkbox 追蹤

0
Avatar
Legacy Poster

I have 3 objects, two text and 1 imported bitmap, that I want to set to "do not print" or "do print" based on a checkbox selected during Data Entry.

 

I therefore wanted to VBScript something like

if Format.NamedSubStrings("checkboxlinkednamedobject").Value = 0 then 

  {set "do not print" property on object 1 to true}

  {set "do not print" property on object 2 to true}

  {set "do not print" property on object 3 to true}

endif

 

so, how do I disable printing of more than one object at Data Entry time?

 

I assumed 

  {set "do not print" property on object 1 to true}

would be coded as

if Format.Objects("object1").DoNotPrint = True

but that doesn't seem to be documented if so.

5 意見

0
Avatar
Fernando Ramos Miracle
版主
評論操作 永久連結

1. The "Do Not Print" setting refers to the "Print Visibility" property of an object (which is certainly documented) so the code would be as follows:

 

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

 

*Note that this code needs to be added in the document level VB script (accessed from the "File>BarTender Document Options..." dialog under the "VB Scripting" tab); you cannot add object references from any other VB script on a document.

 

2. Another option would be to set the value of an object (or its data sources) to "empty". Note that an empty text object/barcode won't print.

 

Format.NamedSubStrings("DataSource").Value = ""

 

This can be done from any VB Script on your document.

0
Avatar
Legacy Poster
評論操作 永久連結

The DesignObject.Value property is documented as read-only.  I can't figure out from the documentation what type the return value from Format.NamedSubStrings() is, it just says "reference", but not to what.

 

I also can't figure out how to read the value of a checkbox on the Data Entry form without creating a hidden text field on the label template.

 

Also, although the event-scripting documentation says one of the available "notable" events is "After a user has pressed OK to close the data entry form." I cannot find a single instance of this event as a choice in either the File>BarTender Document Options..." VB Scripting list, nor in the similar list for any given item on the template.

 

and, the button to close the data entry form is "Print", not OK.

 

Sigh, sorry.  Just taking out my frustration.  Microsoft's help file format (CHM) is the worst POS invented since the previous Microsoft help format.  

 

Is this stuff in a PDF somewhere?

0
Avatar
Fernando Ramos Miracle
版主
評論操作 永久連結

Hello,

 

*No offense taken, scripting can be certainly frustrating (been there too).

 

1. Why would you need to use the "DesignObject" object? Please explain in further detail.

 

In any case, this object doesn't have a "Value" property. It does have "FontBold", "FillColor", "X", "Y", "Width"... but I haven't been able to find a "Value" property for it.

 

2. Unfortunately a Data Entry Control only serves as a information "receiver", it then needs to load that information in a data source in the document to be able to use it. Up to v10.0 of BarTender this would mean needing to create a data source in a label object to receive that data.

 

Please note that in our latest version (v10.1) just released, named data sources are independent of any label object (we've added a named data source menu) so you could link the data entry control with a data source without it actually being in the document.

 

3. When working with the "Document Level VB Scrip" you can use the "OnPrintJobStart" or "OnIdenticalCopies" events in which the data entry form has already been applied.

 

When using a VB Script type data source and setting it to be an event type script, you'll find the event called "OnPostPrompt" which is the one you are looking for.

 

If you don't see this event it's probably the case that you are using the "VB Script" setting under the "Transforms" tab of the data source (on older versións it would be found clicking in the "More Options..." button when selecting a sub string), which only allows for the "OnProcessData" event.

 

4. Indeed the button to close the Data Entry Form is "Print", I'll take a look at the documentation and report it if it certainly needs changing.

 

5. You can find documentation and examples in BarTender's help (both on the general help documentation and the specific VB Script documentation, both found under BarTender's "Help" menu).

 

6. I'm attaching an simple example I did some time ago that changes the colour of a box on the document depending on the value coming from a Data Entry Control. Note that changing the colour works in the same way as changing the visibility. Please take a look at it and let me know if you need further help.

 

*The example is made with v9.4, if you are working with an older BarTender version let me know and I'll adapt it so you can use it.

1
Avatar
Ian Cummings
版主
評論操作 永久連結

Example BarTender document.

0
Avatar
Legacy Poster
評論操作 永久連結

Okay. Success.

 

First, I never got the VB script tied to the OnIdenticalCopies event to work for me, at least not perfectly.  I could use:

 
Format.Objects("DC Optional Text").DoNotPrint = TRUE in a select case or whatever successfully, but not
Format.Objects("DC Optional Picture").DoNotPrint = TRUE, it said "unexpected error on line xxx" every time.
 
However, 10.1 appears to have introduced Object Properties, "Print When", "Conditionally, based on data source", "named data source"-"is equal", and because I am just trying to inhibit the print of three objects, I just set one of these conditions on each object.
 
One thing: I can't find the right way to create a named data source without creating a label, naming it, then deleting the label...  Once I found a button labelled "Manage Named Data Sources", and when I clicked it I was happy, but now I can't figure out where that button was.  Is there a menu item somewhere?   Just found it.  "Data Sources" at the bottom of the "Toolbox", right-click menu. Both create and manage.
 
Anyway, thank you for your help.  Showing/hiding these based on a checkbox will be a great help in reducing the number of label templates needed around here. (cuts the number by about 40%)

登入寫評論。