调试规则触发的Outlook 2007脚本 [英] Debugging an Outlook 2007 script fired by a rule

查看:78
本文介绍了调试规则触发的Outlook 2007脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调试由规则触发的Outlook 2007 VBA脚本.我在脚本中设置了一个断点,但没有命中.

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.

该脚本实际上是ThisOutlookSession对象中的Sub.

The script is actually a Sub in the ThisOutlookSession object.

当我在指定的文件夹上运行规则时,似乎什么也没发生.

When I run the rule on a specified folder nothing seems to happen.

我做错了什么?

更新:

我已经在脚本中添加了MsgBox "Processing: " & mailItem.Subject,并且在运行规则时可以很好地弹出.但是我似乎无法让脚本在断点处停止.

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.

但是,为了调试您的VBA,我建议您创建一个宏(通过工具" |宏" |宏"菜单),该宏使用在宏中创建的测试电子邮件项目调用脚本函数.

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.

也许是这样的:

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屋!

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