Results 1 to 9 of 9
  1. #1
    Lounger
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Error trapping when using routingslip (Word 2003 sp2)

    I have some code that sends the document as an attachment using the routingslip technique. It works fine unless the sender decides not to send the document when asked by Outlook to allow the transimission.

    If they click "NO", they 1) receive a message that the mail service doesn't support certain functions (which I can live with) but 2) then they get a run time error that allows them to click "Debug" and get into the VBA code which is definitely NOT okay.

    I guess I'm not a smart as I think I am because I can't seem to get On Error to trap and avoid the problem.... maybe because it's out in Outlook land???

    Thanks,
    Al

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Error trapping when using routingslip (Word 2003 sp2)

    Welcome to Woody's Lounge!

    Code like this traps the errors correctly, as far as I can tell - I see "Tadaa!" instead of the standard error message if I don't give the code permission to use the Outlook address book or if I provide an ambiguous e-mail address and cancel.

    Sub RouteMyDoc()
    On Error GoTo ErrHandler
    ActiveDocument.HasRoutingSlip = True
    With ActiveDocument.RoutingSlip
    .AddRecipient "you @somewhere.com"
    .Subject = "Routing Test"
    End With
    ActiveDocument.Route
    Exit Sub
    ErrHandler:
    MsgBox "Tadaa!", vbExclamation
    End Sub

  3. #3
    Lounger
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error trapping when using routingslip (Word 2003 sp2)

    Hans - Thanks for the help, but... [isn't there always a but?...<img src=/S/smile.gif border=0 alt=smile width=15 height=15>]

    I still get a run-time error '91' Object variable or With block variable not set.
    Upon clicking "Debug" it points me to the line of code that reads
    .AddRecipient "myname@myaddress.com".

    If I allow the email to go through, I don't receive any errors and delivery is successful.

    Thanks again,
    Al

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Error trapping when using routingslip (Word 2003 sp2)

    If you add an error handler as in the sample code I posted, you shouldn't be offered the standard End / Debug / Help message box, but the simple Tadaa message box defined in the error handling section. I've tried canceling the e-mail at various stages, and each time Tadaa is shown. I'd check carefully that you've really created an error handler.

  5. #5
    Lounger
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error trapping when using routingslip (Word 2003 sp2)

    Hans -

    The code I'm using reads -

    Private Sub cmdSendEmail_Click()

    On Error GoTo ErrRtn
    ActiveDocument.HasRoutingSlip = True
    With ActiveDocument.RoutingSlip
    .Subject = "Monthly PROJECT Dashboard"
    .AddRecipient "alan.Cohen@umassmed.edu"
    .Delivery = wdAllAtOnce
    End With

    ActiveDocument.Route
    ActiveDocument.HasRoutingSlip = False
    MsgBox "Email Transmission Successful!"

    Exit Sub

    ErrRtn:
    MsgBox "Email Transmission Cancelled!"
    ActiveDocument.HasRoutingSlip = False

    End Sub


    I also have
    ActiveDocument.HasRoutingSlip = False
    when I open and close the document to clear out the Routing Slip otherwise I was appending the recipients ad nauseum.

    Thanks for your patience,
    Al

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Error trapping when using routingslip (Word 2003 sp2)

    OK, now I also get the message that the mail service doesn't support certain functions, but after that it goes to the error handling section, it doesn't offer the Debug option.

  7. #7
    Lounger
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error trapping when using routingslip (Word 2003 sp2)

    Hans -

    Problem solved, it was really stupid...

    In VBA, The Options ...General tab...Error Trapping section was set to "Break On All Errors". Changing that to "Break on Unhandled Errors" did the trick.

    Thanks for all your help,
    Al

  8. #8
    Lounger
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error trapping when using routingslip (Word 2003 sp2)

    Hans -

    Of course now I need to figure out how to code how to set the debug option to "Break on All Errors" upon entering the document...[img]/forums/images/smilies/smile.gif[/img]

    Al

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Error trapping when using routingslip (Word 2003 sp2)

    As far as I know, there is no practical way to change the "Error Trapping" setting in code. Anyway, the default setting ("Break on Unhandled Errors") is fine - I see no reason to ever change it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •