Outlook Ribbon Toggle Button

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....

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:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
RoryA,

Thanks for the information. I downloaded the files and am enjoying playing around with them in conjunction with the UI Editor!
 
Upvote 0
You have a world of fun ahead of you... :)
 
Upvote 0

Forum statistics

Threads
1,214,542
Messages
6,120,116
Members
448,945
Latest member
Vmanchoppy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top