Anyone Help Me With Basic Label Print From Script
I'm searching high and low for examples of printing from Excel vba or vbscript; dont care as long as I can find one that works.
All I seem to be finding, are examples that don't work.
I did find one example that works, but need to expand on how I send data to a variable in the label.
Below prints a label I designed with 1 text field. I populated the field with "test". The label prints with the code below.
Sub ThisWorks()
Dim btApp As BarTender.Application
Dim btFormat As BarTender.Format
Set btApp = New BarTender.Application
Set btFormat = New BarTender.Format
btApp.Formats.Open ("c:\os\bob.btw")
btApp.Visible = True
btApp.ActiveFormat.IdenticalCopiesOfLabel = 6
btFormats = btApp.ActiveFormat.PrintOut(False, False)
End Sub
In other examples I've seen:
'Set the ProductName substring data
btFormat.SetNamedSubStringValue("test", "Fruit Loops")
But when I copy this line into excel vba, it errors out; Compile error, expected =.
VBA shows the example methood for handling this line as:
SetNamedSubStringValue(SubStringName As String, Value As String)
I'm confused and would be greateful if someonw could help me move past this
-
Legacy Poster
★ BarTender Hero ★
I did find now that I can use:
btFormat.SetNamedSubStringValue "test", "123545"
But still get an error: The named data source test is not found in the named data source list
I've clicked on the properties of my text object in the abel and selected properties; from there setting data source name to test. What else do I need to do?
0 -
Legacy Poster
★ BarTender Hero ★
Are you naming the correct field?
[attachment=849:Wrong.bmp]
[attachment=850:Correct.bmp]
0 -
Legacy Poster
★ BarTender Hero ★
yes. In my case, blue from your example is "test" from mine.
Here is my vba code.
Sub ThisDoesNotWork()
Dim btApp As BarTender.Application
Dim btFormat As BarTender.Format
Set btApp = New BarTender.Application
Set btFormat = New BarTender.Format
btApp.Formats.Open ("c:\os\bob.btw")
btApp.Visible = False
btFormat.SetNamedSubStringValue "test", "123545"
btApp.ActiveFormat.IdenticalCopiesOfLabel = 1
btFormats = btApp.ActiveFormat.PrintOut(False, False)
End SubThe label prints if I comment out the brformat.setnamedsubstringvalue "test", "12345"
The error: the named data source test is not found in the named data source list
0 -
Legacy Poster
★ BarTender Hero ★
The named datasource is in the label setup, not your VBScript. Can you attach a copy of your label please.
0 -
Legacy Poster
★ BarTender Hero ★
here is my label file
0 -
Legacy Poster
★ BarTender Hero ★
Sorry, I can't help you here. I know when I was playing with the VBScript inside of Bartender there was a point where I used a field in the script that was not on the label. It required that I add a reference line of code to the script in order for the script to recognize the database field properly. I wonder if this is a similar issue, If it is I was not able to find anything about sytanx or verbiage that would help on the internet or in BarTenders help menu.
good luck
0 -
Have you tried using the NamedSubStrings.GetAll() method in order to get a list of all named data sources you've defined in the BT document? Will this give you "test" and "test2" as the named data sources found?
0
Please sign in to leave a comment.
Comments
7 comments