SendObject错误2501 [英] SendObject error 2501

查看:74
本文介绍了SendObject错误2501的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个声明,循环通过表格通过电子邮件发送报告。如果我发送所有电子邮件它工作正常,但如果我取消并发送电子邮件,我得到运行时错误2501无法发送对象。


我有一个错误处理程序到位,但我无法恢复代码。

I have a statement that loops through a table to send a report via email. If I send all the emails it works fine, but if I cancel and email, I get the run-time error 2501 Can''t sendobject.

I have an error handler in place, but I can''t get the code to resume.

展开 | 选择 | Wrap | 行号

推荐答案

您的错误处理程序是错误的。您的选择案例应该测试 Err.Number 而不仅仅是Err。此外,您需要将 Command54_Exit:代码放在 ExitHandler:代码之上,这样如果没有错误发生,您的代码将在转到 ErrorHandler之前退出:
Your error handler is errored. Your Select Case should test for Err.Number not just Err. Also, you need to put your Command54_Exit: code above the ExitHandler: code so that if no error occurs, your code will exit before getting to the ErrorHandler:.


@Seth Schrock


按照建议进行更改,但仍然不会恢复流程。


您是否收到未发送电子邮件?消息框?如果是,当它出现时,按Ctrl + Break。这将使代码进入Break模式并允许您单步执行代码。应突出显示MsgBox行。按F8一次一行地执行代码。这将告诉您正在执行哪些行以及何时执行。回复这些信息,我们可以从那里开始。


我不认为如果从工作中这会停止,但你真的不需要ExitHandler。只需将继续下一步替换为第35行。
Do you get the "eMail not sent" message box? If yes, when it comes up, press Ctrl + Break. This will make the code enter Break mode and allow you to step through the code. The MsgBox line should be highlighted. Press F8 to step through the code one line at a time. This will tell you what lines are being executed and when. Post back this information and we can go from there.

I don''t think that this would stop if from working, but you really don''t need the ExitHandler. Just put Resume Next to replace line 35.


这篇关于SendObject错误2501的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆