Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Asking user to print and error message

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Asking user to print and error message

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

--
Regards,
Tom Ogilvy


"Olly" wrote in message
om...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Print Error Message: Print titles must be contiguous and complete sum1029 Excel Discussion (Misc queries) 1 September 16th 09 07:27 PM
Error Message if user leaves a field blank GillianX Excel Worksheet Functions 1 October 14th 08 05:40 PM
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
How to print when an error message keeps showing? clueless Excel Discussion (Misc queries) 1 January 30th 06 05:33 PM
changing the message in an error message The Villages DA Excel Worksheet Functions 2 February 18th 05 05:30 PM


All times are GMT +1. The time now is 09:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"