1
我想写一个脚本来打开/关闭特定的规则,但它似乎并没有工作。下面是我有:展望VBA Rule.Enabled不工作
Public Sub ToggleFwd()
Dim olRules As Outlook.Rules
Dim olRule As Outlook.Rule
Set olRules = Application.Session.DefaultStore.GetRules
Set olRule = olRules.Item("Forward Mail Info")
If olRule.Enabled = True Then
olRule.Enabled = False
Else
olRule.Enabled = True
End If
End Sub
我也试过在眼前节下面的代码:
Application.Session.DefaultStore.GetRules.Item("Forward Mail Info").Enabled = True
似乎并没有要么做任何事情。什么似乎是问题?
帮自己一个忙:删除'如果...否则... EndIf'块,并使用'Not'逻辑运算符。 'olRule.Enabled = Not olRule.Enabled'。还要注意,在'If'条件下将'Boolean'值/表达式与'Boolean'文字进行比较,总是*过度杀伤。 '如果{bool-expression} Then'就足够了。 –