mrmmickle1
Well-known Member
- Joined
- May 11, 2012
- Messages
- 2,461
I have this Macro that effectively Toggles an Outlook Rule that I have for Delayed Email (2 min delay to keep me from making clerical errors, forgetting attachments, etc....
I know this could be considered overkill but I was wondering Big Picture wise as a concept that I can use in other Excel Projects if it would be possible to Change the Icon/Picture that is associated with the ribbon? For Instance:
If the Rule is Enabled or Set = True the Ribbon Icon/Picture is a Green Check
If the Rule is Disabled or Set = False the Ribbon Icon/Picture is a Red X
I feel this would be useful for other custom add-ins and or macros attached to the ribbon. Any help with getting this to occur using VBA would be great. As always I appreciate the help.
Code:
[COLOR=#008000]' Macro to disable a rule[/COLOR]
[COLOR=#0000ff]Sub[/COLOR] Toggle_Outlook_Rule()
[COLOR=#0000ff] Dim[/COLOR] olRules[COLOR=#0000ff] As [/COLOR]Outlook.Rules
[COLOR=#0000ff] Dim [/COLOR]olRule [COLOR=#0000ff]As [/COLOR]Outlook.Rule
[COLOR=#0000ff] Dim[/COLOR] blnExecute[COLOR=#0000ff] As Boolean[/COLOR]
[COLOR=#0000ff] Set[/COLOR] olRules = Application.Session.DefaultStore.GetRules
[COLOR=#0000ff]Set[/COLOR] olRule = olRules.Item("Email_Delay")
[COLOR=#0000ff] If[/COLOR] olRule.Enabled = T[COLOR=#0000ff]rue Then[/COLOR]
olRule.Enabled = [COLOR=#0000ff]False[/COLOR]
[COLOR=#0000ff] ElseIf [/COLOR]olRule.Enabled =[COLOR=#0000ff] False[/COLOR] [COLOR=#0000ff]Then[/COLOR]
olRule.Enabled = [COLOR=#0000ff]True[/COLOR]
[COLOR=#0000ff] End If[/COLOR]
[COLOR=#0000ff]If[/COLOR] blnExecute [COLOR=#0000ff]Then[/COLOR] olRule.Execute ShowProgress:=[COLOR=#0000ff]True[/COLOR]
olRules.Save
[COLOR=#0000ff] Set[/COLOR] olRules = [COLOR=#0000ff]Nothing[/COLOR]
[COLOR=#0000ff] Set[/COLOR] olRule = [COLOR=#0000ff]Nothing
[/COLOR][COLOR=#000000]blnExecute [/COLOR][COLOR=#0000ff]= False
[/COLOR]
[COLOR=#0000ff]End Sub[/COLOR]
I know this could be considered overkill but I was wondering Big Picture wise as a concept that I can use in other Excel Projects if it would be possible to Change the Icon/Picture that is associated with the ribbon? For Instance:
If the Rule is Enabled or Set = True the Ribbon Icon/Picture is a Green Check
If the Rule is Disabled or Set = False the Ribbon Icon/Picture is a Red X
I feel this would be useful for other custom add-ins and or macros attached to the ribbon. Any help with getting this to occur using VBA would be great. As always I appreciate the help.
Last edited: