【发布时间】:2020-01-25 01:27:46
【问题描述】:
我在 Outlook 365 中收到以下行的错误:
Set colRules = Application.Session.DefaultStore.GetRules
在禁用我的 Outlook 规则的代码中。
“运行时错误:一个或多个规则存在冲突。您必须先解决冲突,然后才能保存规则。”
Sub DisableAllRules()
Dim colRules As Outlook.Rules
Dim oRule As Outlook.Rule
Dim count As Integer
Dim ruleList As String
'On Error Resume Next
'Get Rules from Session.DefaultStore object
Set colRules = Application.Session.DefaultStore.GetRules
' iterate all the rules
For Each oRule In colRules
oRule.Enabled = False
count = count + 1
ruleList = ruleList & vbCrLf & count & ". " & oRule.Name
Next
colRules.Save
'tell the user what you did
ruleList = "These rules were enabled: " & vbCrLf & ruleList
MsgBox ruleList, vbInformation, "Macro: DisableAllRules"
Set colRules = Nothing
Set oRule = Nothing
End Sub
【问题讨论】: