V_is_for_Victory
New Member
- Joined
- Jul 29, 2010
- Messages
- 2
I have code that searches for the correct network node for the selected printers. The problem is that I have a variable getting set with the address to be passed back to be used as the printer.
Need help. I had this code working and then all of a sudden the code stopped working.
Sub FindShiftPrinter_Click(PrinterName)
Dim Msg As String
Dim C As Integer
CheckShiftPrinter:
C = 0
D = 0
On Error GoTo WrongPrinterError:
ResumePrinting:
If C < 40 Then
If C < 10 Then
PrinterName = "\\VJPRINT3\" & Cells(2, 42) & " on Ne0" & C & ":"
Else
PrinterName = "\\VJPRINT3\" & Cells(2, 42) & " on Ne" & C & ":"
End If
Application.ActivePrinter = PrinterName
Else
If D < 40 Then
If D < 10 Then
PrinterName = "\\VJPRINT4\" & Cells(2, 42) & " on Ne0" & C & ":"
Else
PrinterName = "\\VJPRINT4\" & Cells(2, 42) & " on Ne" & C & ":"
End If
Application.ActivePrinter = PrinterName
End If
End If
Exit Sub
WrongPrinterError:
C = C + 1
D = D + 1
Resume ResumePrinting:
End Sub
Section of the code where printing is done:
If Cells(53, 3) = "" Then
Cells(2, 19) = "Date/Time Printed:"
Cells(2, 21) = PDate & " " & PTime & " 1 page"
With Worksheets("Labor Reporting").PageSetup
.PrintArea = "$C$2:$Z$56"
.Orientation = xlLandscape
.BlackAndWhite = True
.Zoom = False
.FitToPagesTall = 1
.FitToPagesWide = 1
.CenterHorizontally = True
.CenterVertically = True
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.25)
.BottomMargin = Application.InchesToPoints(0.5)
End With
Else
Cells(2, 19) = "Date/Time Printed:"
Cells(2, 21) = PDate & " " & PTime & " 2 pages"
With Worksheets("Labor Reporting").PageSetup
.PrintArea = "$C$2:$Z$109"
.PrintTitleRows = ActiveSheet.Rows("$10:$12").Address
.Orientation = xlLandscape
.BlackAndWhite = True
.Zoom = False
.FitToPagesTall = 2
.FitToPagesWide = 1
.CenterHorizontally = True
.CenterVertically = False
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.25)
.RightFooter = "&P"
End With
End If
'This Call finds the correct Network Node (NExx) for the designated printer by area
Call FindShiftPrinter_Click(PrinterName)
Worksheets("Labor Reporting").PrintOut ActivePrinter:=PrinterName
Need help. I had this code working and then all of a sudden the code stopped working.
Sub FindShiftPrinter_Click(PrinterName)
Dim Msg As String
Dim C As Integer
CheckShiftPrinter:
C = 0
D = 0
On Error GoTo WrongPrinterError:
ResumePrinting:
If C < 40 Then
If C < 10 Then
PrinterName = "\\VJPRINT3\" & Cells(2, 42) & " on Ne0" & C & ":"
Else
PrinterName = "\\VJPRINT3\" & Cells(2, 42) & " on Ne" & C & ":"
End If
Application.ActivePrinter = PrinterName
Else
If D < 40 Then
If D < 10 Then
PrinterName = "\\VJPRINT4\" & Cells(2, 42) & " on Ne0" & C & ":"
Else
PrinterName = "\\VJPRINT4\" & Cells(2, 42) & " on Ne" & C & ":"
End If
Application.ActivePrinter = PrinterName
End If
End If
Exit Sub
WrongPrinterError:
C = C + 1
D = D + 1
Resume ResumePrinting:
End Sub
Section of the code where printing is done:
If Cells(53, 3) = "" Then
Cells(2, 19) = "Date/Time Printed:"
Cells(2, 21) = PDate & " " & PTime & " 1 page"
With Worksheets("Labor Reporting").PageSetup
.PrintArea = "$C$2:$Z$56"
.Orientation = xlLandscape
.BlackAndWhite = True
.Zoom = False
.FitToPagesTall = 1
.FitToPagesWide = 1
.CenterHorizontally = True
.CenterVertically = True
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.25)
.BottomMargin = Application.InchesToPoints(0.5)
End With
Else
Cells(2, 19) = "Date/Time Printed:"
Cells(2, 21) = PDate & " " & PTime & " 2 pages"
With Worksheets("Labor Reporting").PageSetup
.PrintArea = "$C$2:$Z$109"
.PrintTitleRows = ActiveSheet.Rows("$10:$12").Address
.Orientation = xlLandscape
.BlackAndWhite = True
.Zoom = False
.FitToPagesTall = 2
.FitToPagesWide = 1
.CenterHorizontally = True
.CenterVertically = False
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.25)
.RightFooter = "&P"
End With
End If
'This Call finds the correct Network Node (NExx) for the designated printer by area
Call FindShiftPrinter_Click(PrinterName)
Worksheets("Labor Reporting").PrintOut ActivePrinter:=PrinterName