Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error on printing
I have the procedure set out below where there may be the situation where a
printer is not connected or there is an error with the printer. Sub printsummarybudget() With Worksheets("SumBud").PageSetup .CenterHorizontally = True .Orientation = xlPortrait .FitToPagesWide = 1 .FitToPagesTall = 1 End With On Error Resume Next Err.Clear Worksheets("SumBud").Range("Sumbud").PrintOut Copies:=1, Preview:=False, Collate:=True If Err.Number < 0 Then MsgBox "There was an error printing or there is no printer attached", vbExclamation, "Printer Problem" On Error GoTo 0 End Sub The problem is when I start the procedure I get a window with the Printer Set-up option of selecting which printer I want to use. It is connected to a network so there is a choice of printer. However if I am not connected and I choose the Cancel option on the printer selection window I get a run-time error 1004 "Unable to set the CentreHorizontally property of the Page Set up Class." I would value any guidance on how to sort this situation. I basically don't want any errors appearing if someone clicks the print procedure when there are no printers attached. The above worked fine if there was only one printer option but not now. Kind Regards, Graham Haughs Turriff, Scotland |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error on printing
Hi, Graham,
Try this way: Sub printsummarybudget() With Worksheets("Sheet1").PageSetup On Error GoTo EndMacro .CenterHorizontally = True .Orientation = xlPortrait .FitToPagesWide = 1 .FitToPagesTall = 1 End With Err.Clear Worksheets("Sheet1").Range("A1:B10").PrintOut Copies:=1, Preview:=False, Collate:=True EndMacro: If Err.Number < 0 Then MsgBox "There was an error printing or there is no printer attached", vbExclamation, "Printer Problem" On Error GoTo 0 End Sub Regards. Jorge "Graham Haughs" escreveu na mensagem ... I have the procedure set out below where there may be the situation where a printer is not connected or there is an error with the printer. Sub printsummarybudget() With Worksheets("SumBud").PageSetup .CenterHorizontally = True .Orientation = xlPortrait .FitToPagesWide = 1 .FitToPagesTall = 1 End With On Error Resume Next Err.Clear Worksheets("SumBud").Range("Sumbud").PrintOut Copies:=1, Preview:=False, Collate:=True If Err.Number < 0 Then MsgBox "There was an error printing or there is no printer attached", vbExclamation, "Printer Problem" On Error GoTo 0 End Sub The problem is when I start the procedure I get a window with the Printer Set-up option of selecting which printer I want to use. It is connected to a network so there is a choice of printer. However if I am not connected and I choose the Cancel option on the printer selection window I get a run-time error 1004 "Unable to set the CentreHorizontally property of the Page Set up Class." I would value any guidance on how to sort this situation. I basically don't want any errors appearing if someone clicks the print procedure when there are no printers attached. The above worked fine if there was only one printer option but not now. Kind Regards, Graham Haughs Turriff, Scotland |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel Printing Error | New Users to Excel | |||
error message during printing | Excel Discussion (Misc queries) | |||
printing error | Excel Discussion (Misc queries) | |||
printing error | Setting up and Configuration of Excel | |||
Printing PDF from Excel Error | Excel Programming |