Hi,
Is there a way to either stop the runtime message that comes up or do a custom message when someone decides not to finish the process of exporting a report to excel?
I have a database with the reports that have the option to export to excel. When someone clicks to export and the prompt comes up as to where to save, if they choose cancel they get the message "The output to was canceled". I would like to either have no message come up or something that doesn't say "runtime error 2501".
Thanks!
Leesha
Debug Message when exporting to excel
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
-
- Administrator
- Posts: 78487
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Debug Message when exporting to excel
I'd use an error handler along these lines:
Code: Select all
Private Sub cmdExport_Click()
On Error GoTo ErrHandler
...
...
Exit Sub
ErrHandler:
If Err = 2501 Then
' Ignore this error
Else
' Display error message
MsgBox Err.Description, vbExclamation
End If
End Sub
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
Re: Debug Message when exporting to excel
Perfect! I will give it a shot. Thanks so much!
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
Re: Debug Message when exporting to excel
Hi Hans,
Finally had time to try this and it worked like a charm.
Thanks!
Leesha
Finally had time to try this and it worked like a charm.
Thanks!
Leesha
-
- Administrator
- Posts: 78487
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
Re: Debug Message when exporting to excel
NP! It took me a little bit to figure out exactly where to place stuff but that was good because I taught me the rationale behind the process for future use.