Print Compatability 追蹤




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()



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!

4 意見

評論操作 永久連結



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

Dim btFormat As

Dim 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

Dim msg As

If (btPrintRtn <>
BarTender.btPrintResult.btSuccess) Then

For Each msg In


Next msg

End If


'End the BarTender process





You also can use Format.PrintOut


'Declare a BarTender application variable 
Dim btApp As BarTender.Application 
'Declare a BarTender document variable 
Dim btFormat As BarTender.Format 
'Create a new instance of BarTender 
btApp = New BarTender.Application
'Open a BarTender document 
btFormat = btApp.Formats.Open("c:\Format1.btw", False, "")
'Print the document 
btFormat.PrintOut(False, False)
'End the BarTender process 
Legacy Poster
評論操作 永久連結

Thanks! I am trying each of these 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?
Legacy Poster
評論操作 永久連結

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?





評論操作 永久連結



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:


Contact details