Outlook 365宏程序禁用所有规则

问题描述 投票:0回答:1

我在Outlook宏(Visual Basic)中的以下一行出现了错误: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
vba rules disable
1个回答
0
投票

我有这个问题。我想这是由某些规则引起的,这些规则不再被Outlook支持,并且在Outlook的规则菜单中以红色高亮显示。我删除了它们,运行时的错误就消失了。

© www.soinside.com 2019 - 2024. All rights reserved.