Converting A Vb6 App (Bartender 7.75)
I am in the process of converting a vb6 app to VB.net (Bartender version 10.1).
The current app prints the labels using the following code
'Build executable string for Bar Tender
strBarTenderExe = frmProcessor.mstrexepath & " /f=" & mstrTextFilePath & "\" & frmProcessor.mstrlblformat
strBarTenderExe = StrBarTenderExe & " /d=" & mstrTextFilePath & "\" & frmProcessor.mstrtextfile & " /p" & " /x"
'Submit Bar Tender label generation job and wait
intshelled = Shell(strBarTenderExe,2)
Looks like it is build some sort of line command to and submits a request to the BarTender exe to print a file.
Couple of question: How does bartender know the printer and number of copies of labels to print?
With version 10.1 of bartender will this still work, is it the most effective way to print a label or should I be using the .Net SDK.
If I am to use the .Net SDK how do I pass the info from the file
Here is the .Net Print Code I have started
Private Sub PrintLabels(ByRef LabelTemplate As String, ByRef PrinterName As String, ByRef NbrofCopies As Integer)
Dim btEngine As New Engine(True)
Try
btEngine.Start()
Dim btFormat As LabelFormatDocument = btEngine.Documents.Open("c:\MyLabel.btw", PrinterName)
btFormat.PrintSetup.IdenticalCopiesOfLabel = NbrofCopies
btFormat.Print()
btEngine.Stop
Catch ex as Exception
End Try
Exit Sub
Any help with this conversion would be greatly appreciated.
Thanks
-
Shotaro Ito
★ BarTender Hero ★
Sure, the command line options /F /P /D /X are still works in BT10.1 Automation or above.
Note that bartend.exe 's location is vary in BarTender / windows x86/x64 versions.
From command line options, you can specify number of copy by /C and printer name by /PRN.
See command line reference in
BarTender help > Automating BarTender > Automation with Command Line Interface > Command Line Parameter Reference.
Going .NET SDK is a good option as it provides much more flexibility.
There's some codes in BarTender help > Automating BarTender > Automation with BarTender .net SDKs > BarTender .net Print SDK > Getting Started.
Note that starting BarTender (engine.start) and terminating bartender (engine.stop) takes time, so try to keep it open while printing jobs.
Consider using Commander / Commander Script too - this could be similar to command line approach and effective as it keep BarTender open and cache formats.
Commander script described in example #3 below.
http://www.seagullscientific.com/label-software/whitepapers/overview-of-commander-new-201406.pdf
Also this troubleshooter is must see..
http://forums.seagullscientific.com/index.php?/topic/55-commander-troubleshooting/
0 -
Legacy Poster
★ BarTender Hero ★
The current application updates a file (containing the data for the btw file). Can you I pass a file to the engine in a similar manner?
0 -
Shotaro Ito
★ BarTender Hero ★
Yes, both Command line and Commander still supports /D="<text database file name>" option to pass data.
From .net SDK it would be like this.
(extract from Getting started in help)
Imports Seagull.BarTender.Print.Database ' Application Code ' ... Dim btEngine As New Engine() ' Start a BarTender print engine btEngine.Start() ' Open a label format Dim btFormat As LabelFormatDocument = btEngine.Documents.Open("c:\MyLabel.btw") ' Set the TextFile database connection file name CType(btFormat.DatabaseConnections("TextFileDB"), TextFile).FileName = "c:\NutritionInformationEurope.txt" ' Print the label format document btFormat.Print() ' Stop the engine btEngine.Stop()
0 -
Legacy Poster
★ BarTender Hero ★
Shotaro
Thanks for your reply. one more question if you don't mind.
VB.net for some reason does not like the ",TextFile" in the databaseConnect command. Error is type TextFile is not defined.
I tried inserting
Dim TextFile as new Seagull.Bartender.Print.Database.TextFile and it did not work.
Here is my subroutine code
Public Sub PrintLabels(ByRef LabelTemplate As String, ByRef PrinterName As String, ByRef NbrofCopies As Integer)
Using btEngine As New Engine(True)
' Start the BarTender print engine.
btEngine.Start()
' Open a format.
Dim btFormat As LabelFormatDocument = btEngine.Documents.Open("C:\lblgen.btw", PrinterName)
' set number of copies
btFormat.PrinterSetUp.IdenticalCopiesofLabel = NbrofCopies
' Set the TextFile database connection file name
CType(btFormat.DatabaseConnections("TextFileDB"),TextFile).FileName = "c:\LabelText.txt"'Print the format
btFormat.Print()
'Close the current format without saving
btFormat.Close(SaveOptions.DoNotSaveChanges)
'Stop bartender engine
btEngine.Stop
End Using
End Sub
What am I doing incorrectly
0 -
Shotaro Ito
★ BarTender Hero ★
Oh... "TextFileDB" is actually the database name of the text database - in default, this is "Text File 1". you can check / rename that in BarTender's database connection setup.
Using code below, it will replace primary text database whatever the database name is.
Dim tf As Seagull.BarTender.Print.Database.TextFile = New Seagull.BarTender.Print.Database.TextFile(btFormat.DatabaseConnections(0).Name) tf.FileName = "C:\data.csv" btFormat.DatabaseConnections.SetDatabaseConnection(tf)
0
請登入寫評論。
評論
5 條評論