G
Graham Haughs
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
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