Aller au contenu principal

Recherche

Recherche

Automating Label Printing From Access Db Random Printers

Commentaires

13 commentaires

  • Avatar
    Ian Cummings
    Modérateur

    How exactly are you controlling BarTender??  Have you wrote some kind of automation script from within Access to control a BarTender process via the automation interface??  See the below white papers for details on what I'm referring to:

     

    http://www.bartenderbarcodesoftware.com/label-software/whitepapers/Controlling-Barcode-Label-Software-using-C-Sharp-and-VB.NET(English).pdf

     

    http://www.bartenderbarcodesoftware.com/label-software/whitepapers/Controlling-Barcode-Label-Software-using-ActiveX-Automation.pdf

    0
  • Avatar
    Legacy Poster

    I've created the call to Bar Tender from within access by using the below coding. This snipet checks for a 64bit version of Windows first so it can use the correct unc to get to where Bar Tender is stored. The two queries are ran it that order to delete the record already in the temporary table used for printing, and replaces it with the record needing printing.

     

     

    Public Function CreateLabels()

    Dim RetVal As Variant
    Dim lngReturn As Long

    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qryDeleteLabelRecord"
    DoCmd.OpenQuery "qryCreateLabel"
    DoCmd.SetWarnings True
           
        Call IsWow64Process(GetCurrentProcess, lngReturn)

        If lngReturn = 0 Then

        DoCmd.SetWarnings False
       
       
        RetVal = Shell("C:\Program Files\Seagull\BarTender Suite\bartend.exe /F=\\10.170.99.9\General\BarTender\DirectPrint\Export\CustomerTri-WallLabel.btw /P /X")
       
        Else
       
        RetVal = Shell("C:\Program Files (x86)\Seagull\BarTender Suite\bartend.exe /F=\\10.170.99.9\General\BarTender\DirectPrint\Export\CustomerTri-WallLabel.btw /P /X")
       
        End If
       
        DoCmd.SetWarnings True
           
    End Function

     

    So instancing Bar Tender is done through the Shell command

     

    Hope this makes sense?

    0
  • Avatar
    Ian Cummings
    Modérateur

    I suggest you make an explicit call on the printer to use in your command line.  For example: /PRN="HP LaserJet 2200D"

     

    I would recommend that you look at the programmed automation solutions in the white papers I sent you as this will give you much better control and performance from your app.

    0
  • Avatar
    Legacy Poster

    I'll take a look into the automation solutions at some point

     

    I'm not sure making an explicit call could work in our situation, as we have a number of users using multiple different printers. The idea behind the label is that it picks up the default printer, which, in theory should work, but it's as if Bar Tender is letting the call get intercepted somehow

     

    Thanks for your help so far

     

    Ryan

    0
  • Avatar
    Legacy Poster

    Ok im struggling with the syntax to make this work in Access (VB)

     

    the white paper is in C# and although i can understand the logic etc, i just can't quite conquer it

     

    I keep getting an 'object required' message every time i use this code

     

    btFormat = btApp.Formats.Open("c:\\test.btw", false, "")

     

    I've declared variables like so:

     

    Dim btApp As BarTender.Application
    Dim btFormat As BarTender.Format
    Dim btMsgs As BarTender.Messages

     

    just for testing purposes i've got a blank form with one command button on it(in Access) to get it up and running

     

    The code in the click event of the button is as above (btFormat = btApp.Formats.Open("c:\\test.btw", false, ""))

     

    Thanks in advance

     

    Ryan

    0
  • Avatar
    Ian Cummings
    Modérateur

    There is a full reference in the BarTender Help system with numerous examples in both C# and VB.NET.  Find this under the "Automating BarTender" topic.

    0
  • Avatar
    Ian Cummings
    Modérateur

    "c:\\test.btw" is an invalid file path.  It should be: "c:\test.btw"

    0
  • Avatar
    Legacy Poster

    VB.Net and VB6 are different though aren't they?

     

    "C:\\test.btw" is the example given in your white sheet BarTenders Active X Automation Interface

     

    I also tried the correct path and still it says 'object required'

     

    Ryan

    0
  • Avatar
    Ian Cummings
    Modérateur

    Did you create the application object?  As in the BarTender process.

     

    Dim btApp As BarTender.Application 
    Set btApp = CreateObject("BarTender.Application")
    btApp.Visible = true
    
    
    0
  • Avatar
    Legacy Poster

    Hello,

     

    Yes i think i'm declaring it right. I'm trying to create an instance of BarTender when my form loads, then as and when i want to print a label it's just a case of accessing the instance already created. The 'getobject' doesn't like working either..........

     

    This is the code in my test form, it errors out on the .print line. I can get it to open a label, though the time it takes isn't any better than using the shell command, though if i can get it printing the app needed become visible so maybe time could be saved there

     

    Let me know your thoughtd

     

    Regards

     

    Ryan

     

    Public Sub Form_Load()

    Dim btApp As BarTender.Application

    End Sub

     

    Public Sub Command0_Click()

     

    Set btApp = CreateObject("BarTender.Application")

    Dim btFormat As BarTender.Format
    Set btFormat = btApp.Formats.Open("c:\test.btw", False, "")
    Dim btMsgs As BarTender.Messages

    btFormat.Print ("Job1")

    btApp.Visible = True

    End Sub

    0
  • Avatar
    Legacy Poster

    I'm getting closer but still can't print as 'object doesn't support this property or method'

     

    Option Compare Database
    Option Explicit

    Dim btApp As BarTender.Application
    Dim btFormat As BarTender.Format
    Dim btMsgs As BarTender.Messages

     

    Public Sub Command0_Click()

    Set btFormat = btApp.Formats.Open("c:\test.btw", False, "")

    btApp.Visible = True

    btFormat.Print "Job1", True, -1, btMsgs

    End Sub

     

    Public Sub Form_Load()

    Set btApp = CreateObject("BarTender.Application")

    End Sub

     

    Any more thoughts on the final steps?

     

    Regards

     

    Ryan

    0
  • Avatar
    Ian Cummings
    Modérateur

    Which line of code is it failing on?

     

    I've not touched VB6 in a long time, but here's an example from the archives.

     

    The following Visual Basic example shows how to change the product name and id on the Demo.btw label format and then print it.  In particular, use the PrintOut() method rather than the Print() method you've used thus far.

     

    'Declare object variables
    Dim btApp As BarTender.Application
    Dim btFormat As BarTender.Format
     
    'Start the Bar Tender application
    Set btApp = CreateObject("BarTender.Application")
    btApp.Visible = true
     
    'Open the Demo.btw format file to print to a laser printer
    Set btFormat = btApp.Formats.Open("c:\Demo.btw",False,"HP LaserJet 2200")
     
    'Set the product name and id on the label.
    btFormat.SetNamedSubStringValue "ProductName", "Bar Tender Integration Edition"
    btFormat.SetNamedSubStringValue "ProductId", "BtInt98234"
     
    'Print the label
    btFormat.PrintOut
     
    btApp.Quit
    
    
    0
  • Avatar
    Legacy Poster

    Ha, great work Ian,

     

    it was erroring on btFormat.Print

     

    All that was holding me back was that..........so now it's bt.Format.PrintOut it works fine!!

     

    Thanks alot for your help

     

    Regards

     

    Ryan

    0

Vous devez vous connecter pour laisser un commentaire.