How To Make Bartender Print Without Dialog Boxes
I am new to this site and new to writing VBA code for Bartender (do have esxperience in VB & VBA for other applications though).
I am trying to write a bit of VBA code that will open a bartender file (which has been set up to pull data from an excel file) and print 1 label and then close without saving the file. The only bit I am having a problem with at the moment is the printing of the label without the prompt box (I don't want the user to have to click the print button in Bartender)!
This is what I have do far:
[code]
Dim btapp As BarTender.Application
Dim btFormat As BarTender.Format
Set btapp = New BarTender.Application
btapp.Formats.Open ("C:\Documents and Settings\C5E16\Desktop\ALC CAN ID LABEL.BTW")
btapp.Visible = True
btFormat.NumberSerializedLabels = 1
btFormat.PrintOut
btapp.Quit (btDoNotSaveChanges)
[/code]
Can anyone tell me how to set up Bartender to print the label without any prompting?
Thanks
Martin
-
1. If you are wanting to control BarTender via automation then you shouldn't really be making the application object visible. Set this property to false.
2. In your label format, for your prompted items give the sub-string in question a share name of some kind. Once this has been done you can set the value of that sub-string via your automation application by using the SetNamedSubStringValue() method of the Format() class. There would be no need to expose a user prompt as the application you are making could set the value of the label object directly. Check the BarTender Help system for more details.
Here is an example of it's use in the BarTender Help reference:
'Declare a BarTender application variable
Dim btApp As BarTender.Application
'Declare a BarTender format variable
Dim btFormat As New BarTender.Format
'Instantiate a BarTender application variable
btApp = new BarTender.ApplicationClass
'Set the BarTender application visible
btApp.Visible = True
'Open a BarTender label format
btFormat = btApp.Formats.Open("c:\Format1.btw", False, "")
'Set the ProductName substring data
btFormat.SetNamedSubStringValue("ProductName", "Fruit Loops")
'Print the label format
btFormat.PrintOut(False, False)
'End the BarTender process
btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges)
*Note: While testing leave the BarTender application object "Visible" property set to true. Once you are sure all is working okay change this to false so that BarTender and any user prompts are hidden.0 -
Legacy Poster
★ BarTender Hero ★
[quote name='Ian C - Seagull Support' timestamp='1321875934' post='1091']
1. If you are wanting to control BarTender via automation then you shouldn't really be making the application object visible. Set this property to false.
2. In your label format, for your prompted items give the sub-string in question a share name of some kind. Once this has been done you can set the value of that sub-string via your automation application by using the SetNamedSubStringValue() method of the Format() class. There would be no need to expose a user prompt as the application you are making could set the value of the label object directly. Check the BarTender Help system for more details.
Here is an example of it's use in the BarTender Help reference:
'Declare a BarTender application variable
Dim btApp As BarTender.Application
'Declare a BarTender format variable
Dim btFormat As New BarTender.Format
'Instantiate a BarTender application variable
btApp = new BarTender.ApplicationClass
'Set the BarTender application visible
btApp.Visible = True
'Open a BarTender label format
btFormat = btApp.Formats.Open("c:\Format1.btw", False, "")
'Set the ProductName substring data
btFormat.SetNamedSubStringValue("ProductName", "Fruit Loops")
'Print the label format
btFormat.PrintOut(False, False)
'End the BarTender process
btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges)
*Note: While testing leave the BarTender application object "Visible" property set to true. Once you are sure all is working okay change this to false so that BarTender and any user prompts are hidden.
[/quote]0 -
Legacy Poster
★ BarTender Hero ★
Thanks Ian C,
I take it that the "Fruit Loops" is the bit of information that you want to print on the label?
I will give this a go and see what happens?
Thanks
Martin0 -
In the example "ProductName" is the name of the sub-string name and "Fruit Loops" is what is to printed on the label itself. 0 -
Legacy Poster
★ BarTender Hero ★
[quote name='Ian C - Seagull Support' timestamp='1322051883' post='1125']
In the example "ProductName" is the name of the sub-string name and "Fruit Loops" is what is to printed on the label itself.
[/quote]
I am using Bartender to pull the label information from an excel spreadsheet which it does fine but just can't get it to print without a dialog box making me press the print button even when the visible = false?
I am using VBA not VB.NET so some of these commands are not working and I am having to try and find the correct code for it? Does anyone have any experience doing this using VBA and not VB.NET?
Thanks for the help so far
Martin0 -
Make sure that you view the BarTender help system for the ActiveX automation. In there you will find some advice for programming with Visual Basic 6, which is pretty much the same as VBA.
Could you include a snippet of the code that you use to call BarTender?
Are you data sourcing the print quantity in any way in the label format, including user prompts?0 -
Legacy Poster
★ BarTender Hero ★
[quote name='Ian C - Seagull Support' timestamp='1322132201' post='1144']
Make sure that you view the BarTender help system for the ActiveX automation. In there you will find some advice for programming with Visual Basic 6, which is pretty much the same as VBA.
Could you include a snippet of the code that you use to call BarTender?
Are you data sourcing the print quantity in any way in the label format, including user prompts?
[/quote]
Here is the code I am using to call and run Bartender:
[code]
Dim btApp As BarTender.Application
Dim btFormat As BarTender.Format
Set btApp = New BarTender.Application
Set btFormat = New BarTender.Format
btApp.Formats.Open ("C:\Documents and Settings\C5E16\Desktop\ALC CAN ID LABEL.BTW")
btApp.Visible = True
btApp.ActiveFormat.IdenticalCopiesOfLabel = 1
btFormats = btApp.ActiveFormat.PrintOut(False, False)
btApp.Quit (btDoNotSaveChanges)
[/code]
This code all works but when it gets to the Printout statement a "Print Wizard - Prompt Dialog" box opens with "Group Box" and then three buttons, Print, Cancel & Help! If I click print then it prints the label ok? This is the bit I want to get rid of and make bartender automatically print the label.
Regards
Martin0 -
I note that this Visible property is set to True, but I guess this is just you testing?
Is there anything on the prompt form like a user prompt for a print operator to input print time data?
In the label format itself, in the "Print" dialog under the "Options" sub-tab you can untick the "Enable Prompting" checkbox, and save the label, which should get rid of this dialog altogether.0 -
Legacy Poster
★ BarTender Hero ★
[quote name='Ian C - Seagull Support' timestamp='1322218688' post='1151']
I note that this Visible property is set to True, but I guess this is just you testing?
Is there anything on the prompt form like a user prompt for a print operator to input print time data?
In the label format itself, in the "Print" dialog under the "Options" sub-tab you can untick the "Enable Prompting" checkbox, and save the label, which should get rid of this dialog altogether.
[/quote]
Thanks for sticking with me Ian it is much appreciated
Nope nothing on the pormpt other than the three buttons I mentioned earlier! I will go and try to find the enable prompting checkbox and untick it, will keep you updated.
Thanks
Martin0 -
Legacy Poster
★ BarTender Hero ★
[quote name='ControlsUK' timestamp='1322219176' post='1152']
Thanks for sticking with me Ian it is much appreciated
Nope nothing on the pormpt other than the three buttons I mentioned earlier! I will go and try to find the enable prompting checkbox and untick it, will keep you updated.
Thanks
Martin
[/quote]
Ian, thanks for all the help with this The last comment you suggested about unticking the prompt box worked a treat, mission accomplished
Thanks again
Martin0 -
Legacy Poster
★ BarTender Hero ★
1. If you are wanting to control BarTender via automation then you shouldn't really be making the application object visible. Set this property to false.
2. In your label format, for your prompted items give the sub-string in question a share name of some kind. Once this has been done you can set the value of that sub-string via your automation application by using the SetNamedSubStringValue() method of the Format() class. There would be no need to expose a user prompt as the application you are making could set the value of the label object directly. Check the BarTender Help system for more details.
Here is an example of it's use in the BarTender Help reference:
'Declare a BarTender application variable
Dim btApp As BarTender.Application
'Declare a BarTender format variable
Dim btFormat As New BarTender.Format
'Instantiate a BarTender application variable
btApp = new BarTender.ApplicationClass
'Set the BarTender application visible
btApp.Visible = True
'Open a BarTender label format
btFormat = btApp.Formats.Open("c:\Format1.btw", False, "")
'Set the ProductName substring data
btFormat.SetNamedSubStringValue("ProductName", "Fruit Loops")
'Print the label format
btFormat.PrintOut(False, False)
'End the BarTender process
btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges)
*Note: While testing leave the BarTender application object "Visible" property set to true. Once you are sure all is working okay change this to false so that BarTender and any user prompts are hidden.Hi,
When the visible property is true, the label is printed. but does not print at all when its false. I am using 10.1 version
Thanks
-a
0
Please sign in to leave a comment.
Comments
11 comments