Вопрос

Я пытаюсь отладить сценарий VBA Outlook 2007, который уволен правилом.Я установил точку останова в скрипте, но он не попадает.

Скрипт на самом деле является генеракодицетагкодом в объекте Sub.

Когда я запускаю правило в указанной папке, кажется, ничего не произойдет.

Что я делаю не так?

<Сильное> Обновление:

Я добавил ThisOutlookSession к сценарию, и это просто отлично, когда я запускаю правило.Однако я не могу получить скрипт, чтобы остановиться на точках останова.

Это было полезно?

Решение

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.

Другие советы

Any existing item can be used to test code that requires one.

Sub passOpenItem()
    'first open an item
    codeRequiringItemParameter ActiveInspector.CurrentItem
End Sub

Sub passSeletion()
    'first select an item
    codeRequiringItemParameter ActiveExplorer.Selection(1)
End Sub

Sub codeRequiringItemParameter(itm As Object)
    Debug.Print "TypeName: " & TypeName(itm)
    Debug.Print "Class...: " & itm.Class
End Sub
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top