Duplicate Labels Created By Bartender 追蹤

0
Avatar
Legacy Poster

My VB.NET application integrates with BarTender 9.4 to produce cleanroom labels.  The user scans a barcode to pre-populate a form then selects a Print button to create the labels.  The labels are produced by populating a BarTender label template file.

 

This works really well but every so often (about once every two months), the user scans the barcode and the previous label is produced.  This happens several times then the software seems to clear itself.  Usually I have to close the software to ensure nothing is running.   

 

I have put code in the software to ensure that the BarTender Format object is disposed of after a print job is finished.  Everything has to be instantiated from fresh every time a print job is sent.  Have also ensured that any variables used are only temporary and are destroyed immediately after use.

 

I have log files in place to capture scanning and printing events and these seem to show that the same barcode is being repeatedly scanned so that would explain the problem but I just am wondering if BarTender could be causing problems.

 

I have included my print sub-routine below including the disposal method after printing.

 

 

 

 

1 意見

0
Avatar
Legacy Poster
評論操作 永久連結

  Public Sub PrintPCSLabel()

        Dim strBarcode As String = ""

        btFormat = btApp.Formats.Open(My.Settings.LabelPath, False, "")


        Try
            btFormat.SetNamedSubStringValue("Lotnumber", clsPrintPCS.PCSIDNo.ToUpper)
        Catch ex As Exception
        End Try

        Try
            btFormat.SetNamedSubStringValue("ItemNumber", clsPrintPCS.ItemNo.ToUpper)
        Catch ex As Exception
        End Try

        strBarcode = "ID" & clsPrintPCS.PCSIDNo.ToUpper & "(BB)" & clsPrintPCS.ItemNo.ToUpper

        Try
            btFormat.SetNamedSubStringValue("Barcode", strBarcode)
        Catch ex As Exception
        End Try


        '//set printer
        btFormat.Printer = My.Settings.Printer


        '//print section
        Dim intNoLabels As Integer = 0
        intNoLabels = clsPrintPCS.NoLabels


        If intNoLabels > 0 Then

            Try
                btFormat.IdenticalCopiesOfLabel = intNoLabels
                btFormat.PrintOut(False, False)

                '//create a print log entry
                UpdateLog(USER.ID, "Printed ItemNo - " + clsPrintPCS.ItemNo.ToUpper + _
                          " BatchNo - " + clsPrintPCS.PCSIDNo.ToUpper + _
                          "  " + ITEM.NoPCSLabels + " DHR Labels")


            Catch eCom As System.Runtime.InteropServices.COMException
                btFormat.Close(BarTender.BtSaveOptions.btDoNotSaveChanges)
                CreateLogFile("Error printing DHR Labels 1", eCom.Message, "PrintPCSLabel")
                MsgBox(eCom.Message)

            Catch ex As Exception
                btFormat.Close(BarTender.BtSaveOptions.btDoNotSaveChanges)
                CreateLogFile("Error printing DHR Labels 2", ex.Message, "PrintPCSLabel")
                MsgBox(ex.Message)
            End Try

        End If


        strBarcode = ""


        '//now close Bartender objects
        Try
            btFormat.Close(BarTender.BtSaveOptions.btDoNotSaveChanges)

        Catch ex As Exception
        Finally

            If Not (btFormat Is Nothing) Then
                Marshal.FinalReleaseComObject(btFormat)
            End If

        End Try

    End Sub


登入寫評論。