Asking user to print and error message

  • Thread starter Thread starter Olly
  • Start date Start date
O

Olly

I am trying to crate some code that asks the user if they want to
print and if the computer encounters an error because there is no
printer installed. How can I adapt my code bellow to allow this to
happen?

Sub PrintInvoice()
Dim Res As Long
Res = MsgBox("Do you want to print the invoice?", vbQuestion +
vbYesNo)
Select Case Res
Case vbYes
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Dim Res As Error
Cas Error("1004")
MsgBox "Error: No print has been found on your
system", vbOKCancel + vbInformation
Case vbNo
Exit Sub
End Select
End Sub

Thanks
Olly
 
Sub PrintInvoice()
Dim Res As Long
Res = MsgBox("Do you want to print the invoice?", vbQuestion +
vbYesNo)
Select Case Res
Case vbYes
On Error Resume Next
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
if err.Number <> 0 then _
MsgBox "Error: " & err.Description, vbOK + vbInformation
Err.clear
On Error goto 0
Case vbNo
Exit Sub
End Select
End Sub

Since you don't offer any choices, your msgbox should just show vbOK
 
Back
Top