Gary Brown
Member
- Outlook version
- Outlook 2013 32 bit
- Email Account
- POP3
Hi,
I have a macro that worked on my old PC but doesn't work on my new PC.
Its an Outlook 2013 32bit VBA module that runs an excising rule in the current folder.
The only difference is my new PC is 64bit both running Windows 7 ultimate.
For clarity my old PC was 32bit.
When initiated I get:
Run-time error '-2147221233 (80040 10f)':
When I run debug I get:
The code gets stuck on line: Next (marked below in red)
The code is as follows:
Sub RunAllInboxRules()
Dim st As Outlook.Store
Dim myRules As Outlook.Rules
Dim rl As Outlook.Rule
Dim runrule As String
Dim rulename As String
rulename = "Spam"
Set st = Application.Session.DefaultStore
Set myRules = st.GetRules
Set cf = Application.ActiveExplorer.CurrentFolder
For Each rl In myRules
If rl.RuleType = olRuleReceive Then
If rl.Name = rulename Then
rl.Execute ShowProgress:=True, Folder:=cf
runrule = rl.Name
End If
End If
Next
ruleList = "Rule was executed correctly:" & vbCrLf & runrule
MsgBox ruleList, vbInformation, "Macro: Spam_Rule_Finished"
Set rl = Nothing
Set st = Nothing
Set myRules = Nothing
End Sub
Any advise and I would be extremely grateful...
regards
Gary (Manchester UK)
I have a macro that worked on my old PC but doesn't work on my new PC.
Its an Outlook 2013 32bit VBA module that runs an excising rule in the current folder.
The only difference is my new PC is 64bit both running Windows 7 ultimate.
For clarity my old PC was 32bit.
When initiated I get:
Run-time error '-2147221233 (80040 10f)':
When I run debug I get:
The code gets stuck on line: Next (marked below in red)
The code is as follows:
Sub RunAllInboxRules()
Dim st As Outlook.Store
Dim myRules As Outlook.Rules
Dim rl As Outlook.Rule
Dim runrule As String
Dim rulename As String
rulename = "Spam"
Set st = Application.Session.DefaultStore
Set myRules = st.GetRules
Set cf = Application.ActiveExplorer.CurrentFolder
For Each rl In myRules
If rl.RuleType = olRuleReceive Then
If rl.Name = rulename Then
rl.Execute ShowProgress:=True, Folder:=cf
runrule = rl.Name
End If
End If
Next
ruleList = "Rule was executed correctly:" & vbCrLf & runrule
MsgBox ruleList, vbInformation, "Macro: Spam_Rule_Finished"
Set rl = Nothing
Set st = Nothing
Set myRules = Nothing
End Sub
Any advise and I would be extremely grateful...
regards
Gary (Manchester UK)