All,
I'm having an issue with the code listed below. When I click submit it just pops up a dialog box to select which printer to use instead of just printing to the targeted active printer. Any ideas?
I'm having an issue with the code listed below. When I click submit it just pops up a dialog box to select which printer to use instead of just printing to the targeted active printer. Any ideas?
VBA Code:
Private Sub Submit_Click()
Dim ws As Worksheet
Dim ws1 As Worksheet
Dim txt1Val As String
Dim lastRow As Long
Worksheets("label template").Visible = False
With Me
txt1Val = .tooltb.Value
End With
Set ws = ThisWorkbook.Worksheets(txt1Val)
ws.Activate
lastRow = ws.Range("A" & Rows.Count).End(xlUp).row + 1
ws.Range("A" & lastRow).Value = Date
ws.Range("B" & lastRow).Value = badgetb.Text
ws.Range("C" & lastRow).Value = depcb.Text
ws.Range("D" & lastRow).Value = assemtb.Text
ws.Range("E" & lastRow).Value = wotb.Text
ws.Range("F" & lastRow).Value = rtstb.Text
ws.Range("G" & lastRow).Value = atmtb.Text
ws.Range("H" & lastRow).Value = bitcb.Text
ws.Range("I" & lastRow).Value = badgetb.Text
Worksheets("label template").Visible = True
Set ws1 = ThisWorkbook.Worksheets("Label Template")
ws1.Activate
ws1.Range("b1").Value = tooltb.Value
ws1.Range("b2").Value = atmtb.Value & " in. lbs."
ws1.Range("b3").Value = "(" & Date & ")"
ws1.Columns("A:B").AutoFit
Dim StrPrn As String
StrPrn = Application.ActivePrinter
Application.ActivePrinter = "ZDesigner TLP 2824 Plus (ZPL) on NE00:"
With ActiveSheet
With .PageSetup
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
With .PageSetup
.PrintArea = "A1:B3"
Application.Dialogs(xlDialogPrinterSetup).Show
ActiveSheet.PrintOut
Application.ActivePrinter = StrPrn
End With
'MsgBox Application.ActivePrinter
End With
ws1.Range("b1").Value = ""
ws1.Range("b2").Value = ""
ws1.Range("b3").Value = ""
Worksheets("label template").Visible = False
badgetb.Value = ""
tooltb.Value = ""
depcb.Value = ""
assemtb.Value = ""
wotb.Value = ""
rtstb.Value = ""
atmtb.Value = ""
bitcb.Value = ""
Workbooks("book1.xlsm").Save
Unload Me
End Sub