Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
691 views
in Technique[技术] by (71.8m points)

vba - Debugging an Outlook 2007 script fired by a rule

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...