Phil Lees
03-14-2017, 10:28 AM
Hello, I'm hoping somebody can help me with this, the code below allows users to print to pdf by clicking a button, but depending on the user, it may or may not work. I have concluded that the "NE" number is to blame, and that it's different between users. Can I alter the code to make it scan through "NE01" onwards, to make sure that this code works for everyone? I thought this code did that anyway, but appears as though it doesn't.
Thanks in advance.
Sub CommandButton2_Click()
ActiveSheet.PageSetup.RightHeader = Format(Now, "MMMM DD, YYYY")
PrtOK = True
Dim Msg As String
Dim C As Integer
Dim PrinterName As String
C = 1
On Error GoTo MakePDFError:
ResumePrinting:
If C < 10 Then
PrinterName = "Adobe PDF on Ne0" & C & ":"
Else
PrinterName = "Adobe PDF on Ne" & C & ":"
End If
Application.ActivePrinter = PrinterName
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"Adobe PDF on Ne04:", collate:=True
Exit Sub
MakePDFError:
C = C + 1
Resume ResumePrinting:
End Sub
Thanks in advance.
Sub CommandButton2_Click()
ActiveSheet.PageSetup.RightHeader = Format(Now, "MMMM DD, YYYY")
PrtOK = True
Dim Msg As String
Dim C As Integer
Dim PrinterName As String
C = 1
On Error GoTo MakePDFError:
ResumePrinting:
If C < 10 Then
PrinterName = "Adobe PDF on Ne0" & C & ":"
Else
PrinterName = "Adobe PDF on Ne" & C & ":"
End If
Application.ActivePrinter = PrinterName
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"Adobe PDF on Ne04:", collate:=True
Exit Sub
MakePDFError:
C = C + 1
Resume ResumePrinting:
End Sub