Hi,
I am having trouble with a VBA code that is giving me an error 2015, also I think I have an error when trying to set the correct Printer_Name.
Please note that I'm using "Application.Inputbox" as I like the way it looks.
I have BOLD the sections that I'm having the problems with, that I am aware of.
Also, is it possible to set the width of the Inputbox?
Here is my current code:
Sub Select_Which_Printer_for_PrintOut()
'Print the Video Tickets
'System Settings
Dim Printer_Name0 As String
Dim Printer_Name1 As String
Dim Printer_Name2 As String
Dim Printer_Name3 As String
Dim Printer_Name4 As String
Dim Printer_Name5 As String
Dim Printer_Temp As String
Dim Printer_Code As Variant
Printer_Name0 = Application.ActivePrinter
Printer_Name1 = "Kodak ESP+7 on Ne01:"
Printer_Name2 = "HP Photosmart B110a Series on Ne02:"
Printer_Name3 = "Lexmark JetPrinter 2030 on ????:"
Printer_Name4 = "< Spare > on ????:"
Printer_Name5 = "< Spare > on ????:"
Printer_Name6 = "< Spare > on ????:"
Printer_Name7 = "< Spare > on ????:"
Printer_Name8 = "< Spare > on ????:"
Printer_Name9 = "< Spare > on ????:"
'Question to Set the Printer to Use
Question:
Printer_Code = Application.InputBox("Please select the Printer you wish to use..." + Chr(10) _ + Chr(10) _ + " Please enter the Number for the Printer..." + Chr(10) _ + Chr(10) _ + " 1. " + Left(Printer_Name1, Len(Printer_Name1) - 9) + "." + Chr(10) _ + " 2. " + Left(Printer_Name2, Len(Printer_Name2) - 9) + "." + Chr(10) _ + " 3. " + Left(Printer_Name3, Len(Printer_Name3) - 9) + "." + Chr(10) _ + " 4. " + Left(Printer_Name4, Len(Printer_Name4) - 9) + "." + Chr(10) _ + " 5. " + Left(Printer_Name5, Len(Printer_Name5) - 9) + "." + Chr(10) _ + " 6. " + Left(Printer_Name6, Len(Printer_Name6) - 9) + "." + Chr(10) _ + " 7. " + Left(Printer_Name7, Len(Printer_Name7) - 9) + "." + Chr(10) _ + " 8. " + Left(Printer_Name8, Len(Printer_Name8) - 9) + "." + Chr(10) _ + " 9. " + Left(Printer_Name9, Len(Printer_Name9) - 9) + "." + Chr(10) _ + Chr(10) _ + Chr(9) + "The Current Printer is " + Chr(147) + Left(Printer_Name0, Len(Printer_Name0) - 9) _ + Chr(148) + "." + Chr(10) _ + Chr(10), "Print Video Tickets...", 1)
'Checking User Input
If Printer_Code = False Then
GoTo Cancel
ElseIf Printer_Code = "" Or Not IsNumeric(Printer_Code) Or Printer_Code < 1 Or _ Printer_Code > 9 Then
GoTo Question
End If
'Selecting which Printer to Use
Printer_Temp = "Printer_Name" + Printer_Code Application.ActivePrinter = Printer_Temp
'Print_Out
'ActiveSheet.PrintOut
MsgBox (Left(Printer_Temp, Len(Printer_Temp) - 9)) 'Delete as for Testing...
Cancel:
Application.ActivePrinter = Printer_Name0
End Sub
Thank you for taking the time to look at my problem.
Neil