为什么运行所有已启用规则的代码不能在outlook-2016中运行?我使用它在outlook 2007,2010和2013上没有任何问题,但它在outlook 2016上不起作用。
Sub OrginalRunActiveCatInboxRules()
Dim Session As Outlook.NameSpace
Dim Report As String
Dim currentItem As Object
Dim currentRule As Outlook.Rule
Dim rules As Outlook.rules
Dim ruleList As String
Set Session = Application.Session
Set rules = Session.DefaultStore.GetRules()
For Each currentRule In rules
If currentRule.RuleType = olRuleReceive Then
'determine if it’s an Inbox rule, if so, run it
If currentRule.Enabled Then
If Left(currentRule.name, 4) = "Cat." Then
MsgBox currentRule.name
currentRule.Execute ShowProgress:=True
' Sortering niet laten zien
' ruleList = ruleList & vbCrLf & currentRule.Name
End If
End If
End If
Next
' tell the user what you did
' ruleList = "These rules were executed against the Inbox: " & vbCrLf & ruleList
' MsgBox ruleList, vbInformation, "Macro: RunAllActiveInboxRules"
Set rules = Nothing
Set currentRule = Nothing
End Sub代码运行到下一步,但在那里给出了一个错误。第一个规则是否启用并不重要,从Cat开始。或者不是。它只是不会转到循环中的下一项,而是生成一个错误。
我该怎么做才能让代码再次工作呢?
发布于 2017-01-27 03:04:50
如果某些规则标记为“来自其他计算机”,请在规则向导中进行检查。如果你有这样的代码,那么代码将在下面的行处中断:
For Each currentRule In rules我现在也有同样的问题--我花了很多时间来解决这个问题。还有一件事可能是个问题:如果违反了任何规则,例如引用了一个不存在的目录,则规则对象将不包含任何规则。
如果对上述问题进行故障排除,请删除所有可疑规则,并开始逐条添加。
发布于 2021-11-27 16:03:25
当我取消选择此选项时,我的一个标记为“在此计算机上”,脚本再次工作。
https://stackoverflow.com/questions/36740713
复制相似问题