Saltar al contenido principal

Búsqueda

Búsqueda

Sample Code: Activex Automation Via Vb Script

Comentarios

13 comentarios

  • Avatar
    Legacy Poster
    Cool, something I've been looking for and will need to try out.
    0
  • Avatar
    Legacy Poster
    Thanks you very much ..
    0
  • Avatar
    Legacy Poster
    Thanks for the code example.

    I have created a VB program as below with a form that has 2 buttons.

    [code]
    Public BtApp As BarTender.Application
    Public BtFormat As BarTender.Format

    Private Sub Command1_Click()
    'button to end the application

    BtApp.Quit (1)

    Set BtFormat = Nothing
    Set BtApp = Nothing

    End

    End Sub


    Private Sub Command2_Click()

    'button to print the label

    'locate the label design
    Set BtFormat = BtApp.Formats.Open("c:\barcode\Label2.btw", False, "")

    'assign the field values
    BtFormat.SetNamedSubStringValue "BCNumber", "M0000000000005"
    BtFormat.SetNamedSubStringValue "BCTitle", "Warehouse 1"


    'print the label
    BtFormat.PrintOut False, False

    'close the app
    BtFormat.Close (1)

    End Sub

    Private Sub Form_Load()

    'define the BarTender application object
    Set BtApp = CreateObject("BarTender.Application")

    'set the captions for Buttons
    Command1.Caption = "Quit"
    Command2.Caption = "Print"

    End Sub

    [/code]

    I have created a label design with 2 share/name fields BCTitle and BCNumber both with empty strings.


    When I run the VB program the barcode prints out but the fields have not been populated with the set values. I have added a fixed text field to check that the correct label file is being accessed.

    Can you explain exactly how to set up a share/name field in a label design as I must be missing something.

    I am using the Trial version of the BarTender software.

    Thanks in advance
    0
  • Avatar
    Shotaro Ito
    Hi GmA,
    To me it looks your code is fine, so that makes me to think your named substring was not setup properly. Please check the format attached with the sample code above.
    Show BarTender window while you set value and print, by
    [code]btApp.Visible = true[/code]
    So you can check any error happened, and actually see the value is updated or not.
    0
  • Avatar
    Legacy Poster
    Thanks for the hint, I suspected it was the label design.

    I have got the label printing now, I think the mistake was setting the Source to Visual Basic Script instead of Screen Data.

    Thanks for the quick and accurate reply.

    GmA
    0
  • Avatar
    Legacy Poster
    Hello
    I am slightly confused and would appreciate guidance
    when I use in VB
    BtFormat.PrintOut False, False
    the format doesn't print but when I set dialog box to open it
    BtFormat.PrintOut True, True
    works when I click the ok button. Is it I am doing something wrong.
    Do I need to add
    btFormat.EnablePrompting = false

    Also If I am using a printer that is on network how do I do identify that in opening of format. Normally I mention the particular zebra printer but the network name of printer is "Zebra1"
    How do I provide the network path of the printer as I am assuming if I put Zebra1 it is going to assume it is local.
    Set BtFormat = BtApp.Formats.Open("c:\barcode\Label2.btw", False, "Zebra1")

    (Zebra1 is network name for Zebra GX230T)
    0
  • Avatar
    Shotaro Ito
    Hi Amit,
    Most likely, you have an error at print time which prevents print, but the error was not shown.
    Show BarTender window while you set value and print, by
    [code]btApp.Visible = true[/code]
    if not.
    Also enable BarTender's message logging (Administer > Log setup > Text file log > Log Messages)

    You don't have to add this line
    [code]btFormat.EnablePrompting = false[/code]
    The code just suppress prompts to pop up. If no prompt has been set to format, prompt dialog not shown.
    The setting is BarTender's Print > Options > Enable prompting.

    To specify network printer from code is "\\<computer name>\<printer name>", which should appear on BarTender's print dialog.
    [code]Set BtFormat = BtApp.Formats.Open("c:\barcode\Label2.btw", False, "\\MYPC\Zebra1")[/code]

    Hope that helps!
    0
  • Avatar
    Legacy Poster
    Thanks for the tip. I found there was error that was not showing because I didnt have the app visible.

    [quote name='Shotaro I -Seagull Support' timestamp='1322616291' post='1178']
    Hi Amit,
    Most likely, you have an error at print time which prevents print, but the error was not shown.
    Show BarTender window while you set value and print, by
    [code]btApp.Visible = true[/code]
    if not.
    Also enable BarTender's message logging (Administer > Log setup > Text file log > Log Messages)

    You don't have to add this line
    [code]btFormat.EnablePrompting = false[/code]
    The code just suppress prompts to pop up. If no prompt has been set to format, prompt dialog not shown.
    The setting is BarTender's Print > Options > Enable prompting.

    To specify network printer from code is "\\<computer name>\<printer name>", which should appear on BarTender's print dialog.
    [code]Set BtFormat = BtApp.Formats.Open("c:\barcode\Label2.btw", False, "\\MYPC\Zebra1")[/code]

    Hope that helps!
    [/quote]
    0
  • Avatar
    Legacy Poster
    Do you know how to get the error message for vb? Like my error message is #3200, which is no records found. I want to be able to do something when that error comes up. Any ideas?
    0
  • Avatar
    Legacy Poster
    Can you please elaborate on how to set the variable data? I have a query (qry_LABEL) that contains the fields that I want printed on my label, but I get a run-time error when I run this code.
    0
  • Avatar
    Legacy Poster

    :o

    0
  • Avatar
    Legacy Poster

    Hi Shotaro,

     

    Could you make available ActiveXsample.zip for download. It's not available now.

    0
  • Avatar
    Shotaro Ito

    Sorry the forum banned zip long ago - this still works with BT2016R3. Place both files on the same folder, rename ActiveXPrint.vbs.txt to ActiveXPrint.vbs and run.

    0

Iniciar sesión para dejar un comentario.