Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JT JT is offline
external usenet poster
 
Posts: 234
Default Error when user clicks "no"

Following is the code used to attach an Excel file to an Outlook message.
Occassionally, users will click "NO" when they get the outlook message. I
would like to put them in a loop that forces them to click "YES"

This code works well the first time. When they click "NO" it throws the
code to the error handler. Then the macro tries to re-send the attachment a
second time. If you click "NO" a second time, it doesn't go to the error
handler but instead produces a run time error. The run-time error is as
follows: General Mail Failure. Quit Microsoft Office Excel, re-start the
mail system and try again.

' the code does stuff

DoMo

On Error GoTo errmsg

ActiveWorkbook.SendMail Recipients:="(email address)", Subject:=FileName


ActiveWorkbook.Close (True)

msgbox "Your file has been sent for processing"

' the code does more stuff

Exit Sub

errmsg:
msgbox "You have clicked the NO button. You must click YES to send your
file."
Err.Clear
GoTo DoMore

Any suggestions or ideas on changing the code would be appreaciated. Thanks
for all of the help with this issue.
--
JT
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Error when user clicks "no"

Try to use also this in the errmsg:

On Error GoTo 0


Sub test()
On Error Resume Next
ActiveWorkbook.SendMail ", _
"This is the Subject line"
On Error GoTo 0
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"JT" wrote in message ...
Following is the code used to attach an Excel file to an Outlook message.
Occassionally, users will click "NO" when they get the outlook message. I
would like to put them in a loop that forces them to click "YES"

This code works well the first time. When they click "NO" it throws the
code to the error handler. Then the macro tries to re-send the attachment a
second time. If you click "NO" a second time, it doesn't go to the error
handler but instead produces a run time error. The run-time error is as
follows: General Mail Failure. Quit Microsoft Office Excel, re-start the
mail system and try again.

' the code does stuff

DoMo

On Error GoTo errmsg

ActiveWorkbook.SendMail Recipients:="(email address)", Subject:=FileName


ActiveWorkbook.Close (True)

msgbox "Your file has been sent for processing"

' the code does more stuff

Exit Sub

errmsg:
msgbox "You have clicked the NO button. You must click YES to send your
file."
Err.Clear
GoTo DoMore

Any suggestions or ideas on changing the code would be appreaciated. Thanks
for all of the help with this issue.
--
JT



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Error when user clicks "no"

Without seeing more code I can not fix the error, so here is a general
explanation of what is going on. When code is running a procedure it is in
normal execution mode until it hits an error and then it switches to error
mode. The exection will continue in error mode until the key word resume is
encountered. When code is in error mode it can not deal with any new errors
until the previous error is dealt with (using resume). So your code exits
normal exectution when the error is encountered and never resumes normal
exectution. The next error can not be handled becuase the code is in error
mode...
--
HTH...

Jim Thomlinson


"JT" wrote:

Following is the code used to attach an Excel file to an Outlook message.
Occassionally, users will click "NO" when they get the outlook message. I
would like to put them in a loop that forces them to click "YES"

This code works well the first time. When they click "NO" it throws the
code to the error handler. Then the macro tries to re-send the attachment a
second time. If you click "NO" a second time, it doesn't go to the error
handler but instead produces a run time error. The run-time error is as
follows: General Mail Failure. Quit Microsoft Office Excel, re-start the
mail system and try again.

' the code does stuff

DoMo

On Error GoTo errmsg

ActiveWorkbook.SendMail Recipients:="(email address)", Subject:=FileName


ActiveWorkbook.Close (True)

msgbox "Your file has been sent for processing"

' the code does more stuff

Exit Sub

errmsg:
msgbox "You have clicked the NO button. You must click YES to send your
file."
Err.Clear
GoTo DoMore

Any suggestions or ideas on changing the code would be appreaciated. Thanks
for all of the help with this issue.
--
JT

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Error when user clicks "no"

Hello JT,

use 'Resume' instead of 'GoTo DoMore'. This will terminate the ongoing
error handling and get you back to 'normal' macro execution. Error
handling within an ongoing error handling process is not an option.
This will always produce a run time error.

Regards,
Ingolf



JT schrieb:

Following is the code used to attach an Excel file to an Outlook message.
Occassionally, users will click "NO" when they get the outlook message. I
would like to put them in a loop that forces them to click "YES"

This code works well the first time. When they click "NO" it throws the
code to the error handler. Then the macro tries to re-send the attachment a
second time. If you click "NO" a second time, it doesn't go to the error
handler but instead produces a run time error. The run-time error is as
follows: General Mail Failure. Quit Microsoft Office Excel, re-start the
mail system and try again.

' the code does stuff

DoMo

On Error GoTo errmsg

ActiveWorkbook.SendMail Recipients:="(email address)", Subject:=FileName


ActiveWorkbook.Close (True)

msgbox "Your file has been sent for processing"

' the code does more stuff

Exit Sub

errmsg:
msgbox "You have clicked the NO button. You must click YES to send your
file."
Err.Clear
GoTo DoMore

Any suggestions or ideas on changing the code would be appreaciated. Thanks
for all of the help with this issue.
--
JT


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
Shortcut key for "Paste Options" and "Error Checking" buttons? johndog Excel Discussion (Misc queries) 1 October 6th 06 11:56 AM
What is Error "Method "Paste" of object "_Worksheet" failed? vat Excel Programming 7 February 17th 06 08:05 PM
"Subscript out of range" error for: Workbooks("Test1.xls").Save Just12341234 Excel Programming 2 June 17th 05 03:16 PM
"Clean Me" Macro is giving "#VALUE!" error in the Notes field. Ryan Watkins Excel Programming 1 June 11th 05 12:25 AM
Getting "compile error" "method or data member not found" on reinstall Bp Excel Programming 1 April 23rd 04 04:42 PM


All times are GMT +1. The time now is 04:14 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"