📄 batchelor.frm
字号:
'Set imgBTFormat to become visible on the form.
imgBTFormat.Visible = True
'If the label format opens then Export the image to the form
If m_bOpenFormatFailed = False Then
BtFormat.ExportToClipboard btColors16, btResolutionScreen 'export image to clipboard
imgBTFormat.Picture = Clipboard.GetData(vbCFDIB) 'Get the data from the clip board to display this.
End If
'Enable the Send Text, Print and Save buttons
Toolbar1.Buttons.Item(3).Enabled = True '3 = Send Text
Toolbar1.Buttons.Item(4).Enabled = True '4 = Save Format
Toolbar1.Buttons.Item(5).Enabled = True '5 = Print Batch
'Enable the Send Text, Print and Save menu options.
mnuSendText.Enabled = True
mnuSave.Enabled = True
mnuPrintBatch.Enabled = True
Else
imgBTFormat.Visible = False 'if there are no formats selected the throw up a message box
MsgBox "You must first high-light a Format to be previewed from the BarTender Formats list.", vbInformation, "Batchelor"
End If
Exit Sub
ErrorHandler:
p_ErrorHandler
End Sub
Private Sub cmdPrint_Click()
On Error GoTo ErrorHandler
Dim GetListCount As Integer ' define an integer to count the formats in BT.
Dim X As Long 'Define an Integer to use to count batch copies
Dim Y As Long 'Define an Integer to use to count how many labels it's printed
GetListCount = Batchelor.list_Formats.ListCount
m_iIgnoreAllErrorsFlag = 0 'Resets the ignore all flags Variable to off.
m_bOpenFormatFailed = False 'If it gets to this point then it succeeded in opening the format.
If GetListCount > 0 Then 'if there's anything in the Formats List then...
For Y = 1 To txtNumberOfBatchCopies.Text 'keeps track of how many batches you've printed.
For X = 0 To (GetListCount - 1) 'For Each format in the list print them out.
m_sSelectedFormat = list_Formats.List(X) 'get the name of the format from the list
p_OpenFormat 'Go to the OpenFormat procedure and open the labels.
If m_bOpenFormatFailed = False Then 'If the format opens then procede.
If chkUseSpecifiedAmountinFormat.Value = 0 Then
BtFormat.IdenticalCopiesOfLabel = txtNumberOfIdenticalCopies.Text
BtFormat.NumberSerializedLabels = txtNumberOfSerializedCopies.Text
End If
BtFormat.PrintOut 'Print the Label Format out
End If
m_bOpenFormatFailed = False
Next
Next
End If
Exit Sub
ErrorHandler:
'Goto the Error
p_ErrorHandler
Resume Next
End Sub
Private Sub cmdRemove_Click()
'Remove the highlighted item in the "BarTender Formats" list
'as long as there's something in the list.
If list_Formats.ListIndex <> -1 Then
list_Formats.RemoveItem (list_Formats.ListIndex)
End If
If list_Formats.ListCount = 0 Then
Toolbar1.Buttons.Item(3).Enabled = False '3 = Send Text
Toolbar1.Buttons.Item(4).Enabled = False '4 = Save Format
Toolbar1.Buttons.Item(5).Enabled = False '5 = Print Batch
imgBTFormat.Visible = False
'Disable the Send Text, Print and Save menu options.
mnuSendText.Enabled = False
mnuSave.Enabled = False
mnuPrintBatch.Enabled = False
End If
End Sub
Private Sub cmdSubStringsProcedure_Click()
On Error GoTo ErrorHandler
'Checks to make sure that there's a format path and name in the Format's list
If list_Formats.ListIndex <> -1 Then
If BtApp.Formats.Count > 0 Then 'check to make sure that a label format is acutally open in BarTender.
If BtFormat.NamedSubStrings.Count > 0 Then 'Checks to make sure that the format has Sub-strings
dbxSendTextToLabel.Show vbModal, Me ' if all conditions pass then show the dialog box.
Else
'if the selected format doesn't have any sub strings then show this message...
MsgBox "The format selected contains no Named Sub-Strings.", vbExclamation, "Batchelor"
End If
Else
'If there are no label formats open within Bartender then display this message...
MsgBox "Please select a valid label format from the Label Formats List", vbExclamation, "Batchelor"
End If
Else
imgBTFormat.Visible = False 'if there are no formats selected the throw up a message box
MsgBox "You must first high-light a Format to be previewed from the BarTender Formats list.", vbInformation, "Batchelor"
End If
Exit Sub
ErrorHandler:
p_ErrorHandler
Exit Sub
End Sub
Private Sub cmdVisible_Click()
'Make the Bartender visible if it is Not Visible OR Else
'Make the BarTender Invisible if it is Visible
If m_bBtVisibility = False Then
BtApp.Visible = True
m_bBtVisibility = True
Else
BtApp.Visible = False
m_bBtVisibility = False
End If
End Sub
Private Sub Form_Load()
'On loading the form if we get an error
'Goto the Error Handler at the bottom of this procedure.
On Error GoTo ErrorHandler
'Here is where we're Starting the Bartender Application
'At the time of loading this program. We've delclared
'the variable in the "PublicVariables Module".
'****************************************************
Set BtApp = CreateObject("Bartender.Application") '*
'****************************************************
'Make BarTender not seen
BtApp.Visible = False
'Flag that Bartender is invisible
m_bBtVisibility = False
'Declaring a variable for the printers
Dim X As Printer
'Get the names of printers installed on the system
For Each X In Printers
cboWhatPrinter.AddItem X.DeviceName
Next
'sets the combo box to the current printer.
cboWhatPrinter.Text = Printer.DeviceName
'Centers the Form on the screen
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
'Sets the "Suppress Page Setup Error" to not skip the error message box.
m_iIgnoreAllErrorsFlag = 0
'Disable and Change the color of the Background of the identical and Serialize copies field.
txtNumberOfIdenticalCopies.Enabled = False
txtNumberOfSerializedCopies.Enabled = False
txtNumberOfSerializedCopies.BackColor = -2147483644
txtNumberOfIdenticalCopies.BackColor = -2147483644
Exit Sub
ErrorHandler:
'If the Bartender Pro/integrator or Enterprise software is not on
'the system then give this error message.
If Err.Number = 429 Then
MsgBox "You have not installed the BarTender Professional Integrator Package " & _
vbCrLf & "or the BarTender Enterprise Edition software. Please install either one" & vbCrLf & _
"of these packages before starting the Batchelor.", vbExclamation, "Batchelor"
Unload Batchelor
End If
'if no printer drivers are installed on this machine then come up with the
'error message
If Err.Number = 484 Then
MsgBox "You have not installed a Printer on this system, therefore the Batchelor" & vbCrLf & _
"cannot print. Please install a printer driver and restart the Batchelor.", vbExclamation, "Batchelor"
Unload Batchelor
Else
MsgBox "Error Number: " & Err.Number & vbCrLf & vbCrLf & vbCrLf & Err.Description, vbExclamation, "Batchelor"
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
'Closing the BarTender Application and the format if there is one.
BtFormat.Close btDoNotSaveChanges
BtApp.Quit
End Sub
Private Sub imgBTFormat_DblClick()
'Item(3) is = SendSub-string button.
If Toolbar1.Buttons.Item(3).Enabled = True Then
mnuSendText_Click
End If
End Sub
Private Sub list_Formats_DblClick()
'Runs the ExportOpen menu option which Exports then opens the format.
mnuExportOpen_Click
End Sub
Private Sub mnuExit_Click()
'Unloads the form and the label formats.
Unload Me
End Sub
Private Sub mnuPrintBatch_Click()
On Error GoTo ErrorHandler
'
Dim GetListCount As Integer
Dim X As Long
Dim Y As Long
GetListCount = Batchelor.list_Formats.ListCount
m_iIgnoreAllErrorsFlag = 0
m_bOpenFormatFailed = False
If GetListCount > 0 Then 'if there's anything in the Formats List then...
For Y = 1 To txtNumberOfBatchCopies.Text
For X = 0 To (GetListCount - 1)
m_sSelectedFormat = list_Formats.List(X) 'get the name of the format from the list
p_OpenFormat 'Go to the OpenFormat procedure and open the labels
If m_bOpenFormatFailed = False Then
If chkUseSpecifiedAmountinFormat.Value = 0 Then
BtFormat.IdenticalCopiesOfLabel = txtNumberOfIdenticalCopies.Text
BtFormat.NumberSerializedLabels = txtNumberOfSerializedCopies.Text
End If
BtFormat.PrintOut 'Print the Label Format out
End If
m_bOpenFormatFailed = False
Next
Next
End If
Exit Sub
ErrorHandler:
p_ErrorHandler
Resume Next
End Sub
Private Sub mnuSave_Click()
BtFormat.Save
End Sub
Private Sub mnuSendText_Click()
On Error GoTo ErrorHandler
'Checks to make sure that there's a format path and name in the Format's list
If list_Formats.ListIndex <> -1 Then
If BtApp.Formats.Count > 0 Then 'check to make sure that a label format is acutally open in BarTender.
If BtFormat.NamedSubStrings.Count > 0 Then 'Checks to make sure that the format has Sub-strings
dbxSendTextToLabel.Show vbModal, Me ' if all conditions pass then show the dialog box.
Else
'if the selected format doesn't have any sub strings then show this message...
MsgBox "The format selected contains no Named Sub-Strings.", vbExclamation, "Batchelor"
End If
Else
'If there are no label formats open within Bartender then display this message...
MsgBox "Please select a valid label format from the Label Formats List", vbExclamation, "Batchelor"
End If
Else
imgBTFormat.Visible = False 'if there are no formats selected the throw up a message box
MsgBox "You must first high-light a Format to be previewed from the BarTender Formats list.", vbInformation, "Batchelor"
End If
Exit Sub
ErrorHandler:
p_ErrorHandler
Exit Sub
End Sub
Private Sub mnuVisible_Click()
'Make the Bartender visible if it is Not Visible OR Else
'Make the BarTender Invisible if it is Visible
If m_bBtVisibility = False Then
BtApp.Visible = True
m_bBtVisibility = True
Else
BtApp.Visible = False
m_bBtVisibility = False
End If
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
Case "Visibility": mnuVisible_Click ' use the function stored in the mnuVisible Procedure
Case "Export": mnuExportOpen_Click ' use the function stored in the mnuExport Procedure
Case "SendText": mnuSendText_Click ' use the function stored in the mnuSendText Procedure
Case "Print": mnuPrintBatch_Click ' use the function stored in the mnuPrintBatch Procedure
Case "Save": mnuSave_Click ' use the function stored in the mnuSave Procedure
End Select
End Sub
Private Sub txtNumberOfBatchCopies_KeyPress(KeyAscii As Integer)
'Allow only numerics to be typed in the Number of Batch Copies text box
If (KeyAscii <> 48) And _
(KeyAscii <> 49) And _
(KeyAscii <> 50) And _
(KeyAscii <> 51) And _
(KeyAscii <> 52) And _
(KeyAscii <> 53) And _
(KeyAscii <> 54) And _
(KeyAscii <> 55) And _
(KeyAscii <> 56) And _
(KeyAscii <> 57) And _
(KeyAscii <> 8) Then
KeyAscii = 0
End If
End Sub
Private Sub txtNumberOfIdenticalCopies_KeyPress(KeyAscii As Integer)
'Allow only numerics to be typed in the Number of Identical Copies text box.
If (KeyAscii <> 48) And _
(KeyAscii <> 49) And _
(KeyAscii <> 50) And _
(KeyAscii <> 51) And _
(KeyAscii <> 52) And _
(KeyAscii <> 53) And _
(KeyAscii <> 54) And _
(KeyAscii <> 55) And _
(KeyAscii <> 56) And _
(KeyAscii <> 57) And _
(KeyAscii <> 8) Then
KeyAscii = 0
End If
End Sub
Private Sub txtNumberOfSerializedCopies_KeyPress(KeyAscii As Integer)
'Allow only numerics to be typed in the Number of Serialized Copies text box.
If (KeyAscii <> 48) And _
(KeyAscii <> 49) And _
(KeyAscii <> 50) And _
(KeyAscii <> 51) And _
(KeyAscii <> 52) And _
(KeyAscii <> 53) And _
(KeyAscii <> 54) And _
(KeyAscii <> 55) And _
(KeyAscii <> 56) And _
(KeyAscii <> 57) And _
(KeyAscii <> 8) Then
KeyAscii = 0
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -