Outlook generates error when accessing rules - Please help.

D

Dennis Macdonald

Hi,

I have 11 rules created and with the code below, outlook generates an
error on the 4th rule.

Note, after the 'Set myRules = st.GetRules' command under the debugger
the count protery is 11 as it should be.

All the rules created seem to be similar in design so there seens to
be no real difference btween the 3rd and 4th rules.

Can anyone explain why?


Sub RunSpecificRules()
Dim st As Outlook.Store
Dim myRules As Outlook.Rules
Dim rl As Outlook.Rule
Dim intCount As Integer

On Error GoTo Process_Error

intCount = 0

'Get default store (where rules live)
Set st = Application.Session.DefaultStore
'Get rules
Set myRules = st.GetRules

'Iterate all the rules
For Each rl In myRules
Debug.Print rl.Name
intCount = intCount + 1
Next

MsgBox "Finished - Count = " & intCount
GoTo Cleanup

Process_Error:
MsgBox "Got Error - Count = " & intCount

Cleanup:
Set rl = Nothing
Set st = Nothing
Set myRules = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top