调试由规则触发的 Outlook 2007 脚本 [英] Debugging an Outlook 2007 script fired by a rule
问题描述
我正在尝试调试由规则触发的 Outlook 2007 VBA 脚本.我在脚本中设置了一个断点,但它没有被命中.
该脚本实际上是 ThisOutlookSession
对象中的一个 Sub
.
当我在指定文件夹上运行规则时,似乎什么也没发生.
我做错了什么?
更新:
我添加了一个 MsgBox "Processing: " &mailItem.Subject
到脚本,当我运行规则时弹出就好了.但是我似乎无法让脚本在断点处停止.
我认为您可能没有做错任何事情,因为我也遇到过完全相同的行为.
但是,为了调试您的 VBA,我建议您创建一个宏(通过工具"|宏"|宏"菜单),用您在宏中创建的测试电子邮件项调用您的脚本函数.>
也许是这样的:
Sub TestScript()将 testMail 调暗为 MailItem设置 testMail = Application.CreateItem(olMailItem)testMail.Subject = "测试主题"testMail.Body = "测试正文"Project1.ThisOutlookSession.YourScriptForDebugging testMail结束子
通过这种方式,您可以再次通过该宏对话框进入"宏,并进行所有需要的调试.无论如何,它解决了我的问题.
I'm trying to debug an Outlook 2007 VBA script that's fired by a rule. I've set a breakpoint in the script but it doesn't get hit.
The script is actually a Sub
in the ThisOutlookSession
object.
When I run the rule on a specified folder nothing seems to happen.
What am I doing wrong?
Update:
I've added a MsgBox "Processing: " & mailItem.Subject
to the script and that pops up just fine when I run the rule. However I can't seem to get the script to stop on breakpoints.
I think you may not be doing anything wrong, because I have experienced exactly the same behaviour.
However, in order to debug your VBA, I suggest that you create a macro (via the Tools|Macro|Macros menu) that calls your script function with a test e-mail item that you create in the macro.
Maybe something like this:
Sub TestScript()
Dim testMail As MailItem
Set testMail = Application.CreateItem(olMailItem)
testMail.Subject = "Test subject"
testMail.Body = "Test body"
Project1.ThisOutlookSession.YourScriptForDebugging testMail
End Sub
This way you can "Step Into" the macro via that Macro dialog again, and do all the debugging you need. It solved my problem, anyway.
这篇关于调试由规则触发的 Outlook 2007 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!