Print Compatability
Hello
I have worked out almost the kinks in my program except this one, and it seems I can't overcome it!
I have very little VBA programming experience (I just started last week actually). I am trying to link a very basic serial number generator programmed in Access 2010 with BarTender (BT) 10.1. Actually, I have already written the code for this, and it works! But just before the last line of code of the private sub executes, the Run-time error '438' message comes up. I will paste my code below. Can someone help me with the formatting of this last line of code?
Private Sub Command35_Click()
Dim LastSN As Long
Dim Counter As Integer
Dim x As Integer
Dim bt As BarTender.Application
Dim frm As BarTender.Format
Set bt = New BarTender.Application
Application.DoCmd.SetWarnings False
DoCmd.OpenQuery "Yes/No"
Forms("TblSerialNumbers").Controls("SN20").Locked = False
Counter = 0
x = txtQty / 20
Do While Counter <= x
LastSN = SN20
DoCmd.GoToRecord , "", acNewRec
Counter = Counter + 1
SN1 = LastSN + 1
SN2 = LastSN + 2
SN3 = LastSN + 3
SN4 = LastSN + 4
SN5 = LastSN + 5
SN6 = LastSN + 6
SN7 = LastSN + 7
SN8 = LastSN + 8
SN9 = LastSN + 9
SN10 = LastSN + 10
SN11 = LastSN + 11
Sn12 = LastSN + 12
SN13 = LastSN + 13
SN14 = LastSN + 14
SN15 = LastSN + 15
SN16 = LastSN + 16
SN17 = LastSN + 17
SN18 = LastSN + 18
SN19 = LastSN + 19
SN20 = LastSN + 20
TextDate = Now()
Loop
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenQuery "TempQ"
DoCmd.OpenQuery "DelQ"
DoCmd.OpenQuery "TQ"
Forms("TblSerialNumbers").Controls("SN20").Locked = True
Set frm = bt.Formats.Open("C:\Users\212393675\Documents\BarTender\BarTender Documents\Labels\Fixt.btw", False, "")
frm = bt.Formats.Print
bt.Quit (btDoNotSaveChanges)
End Sub
I have tried using PrintOut commands, and even went as far as using a Shell command (which sadly, and quite obviously didn't work) and only this works. I have made the BT windos visible, it seems it may be more of a VBA error than a BT error. I was wondering if there is any way to command BT to print from VBA that doesn't have VBA angry at me in the end. Thanks!
-
Hello,
Thank you very much for your post.
A BarTender document can be printed by calling either the Format.Print method or the Format.PrintOut method. The Format.Print method prints a job to a printer's spooler and returns a BtPrintResult enumeration value. It can either return immediately after spooling the print job or wait to return until printing is complete.The Format.PrintOut method will simply execute a print job, giving you the option to display a print job status dialog and/or the print dialog.Here you will find a sample about how to do it with Format.Print
'Declare BarTender variables
Dim btApp As
BarTender.ApplicationDim btFormat As
BarTender.FormatDim btPrintRtn As BarTender.BtPrintResult
Dim btMsgs As
BarTender.Messages = Nothing'Create a new instance of BarTender
btApp = New BarTender.Application
'Set the BarTender application visible
btApp.Visible = True
'Open a BarTender document
btFormat = btApp.Formats.Open("c:\Format1.btw", False, "")
'Print the document
btPrintRtn = btFormat.Print("Job1", True, -1, btMsgs)
'Check to see if there are any error
messagesDim msg As
BarTender.MessageIf (btPrintRtn <>
BarTender.btPrintResult.btSuccess) ThenFor Each msg In
btMsgsMessageBox.Show(msg.Message)
Next msg
End If
'End the BarTender process
btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges)
You also can use Format.PrintOut
'Declare a BarTender application variableDim btApp As BarTender.Application'Declare a BarTender document variableDim btFormat As BarTender.Format'Create a new instance of BarTenderbtApp = New BarTender.Application'Open a BarTender documentbtFormat = btApp.Formats.Open("c:\Format1.btw", False, "")'Print the documentbtFormat.PrintOut(False, False)'End the BarTender processbtApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges)Thanks,Carlos0 -
Thanks! I am trying each of these now...one question though:
For the PrintOut method, any time I try to open a BT document with the code you have, I get a syntax error. It seems to only accept
Set btFormat = btApp.Formats.Open("c:\Format1.btw", False, "")
And then for some reason the line afterwards also pops up a syntax error
btFormat.PrintOut(False, False)What am I doing wrong?0 -
Hey Carlos,
The first method using the format.Print method works for me. Is there a way to do this without opening BT?
Also, I am currently operating with the Trial version. An error box that popped up said that BT was operating in "demonstration mode". Will demonstration mode turn off once I purchase the full version of BT?
Thanks,
Baltad
0 -
Hello,
If you are integrating BarTender, you will need to open it, there is not other way to do it unless you will be able to create a Windows Service (but we cannot provide you support on it).
Once that you will purchase BarTender the Demonstration mode message will turn off. If you want, you also can contact us in order to get a Trial Extension code:
Thanks,
Carlos.
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
4 Kommentare