Home > Net >  Show/Hide ToDo-Bar in Outlook with VBA
Show/Hide ToDo-Bar in Outlook with VBA

Time:06-09

I am not so new to VBA but new to the object model of Outlook VBA. What I currently try, is simply show/hide the To-Do Bar in the E-Mail-View with VBA.

enter image description here

But I could not find in the object model, where to look and change the visible property.

Did you have a suggestion?

Greetings, Thomas

CodePudding user response:

There is a control ID at the end of the text when hovering over a button to be added to the QAT or a ribbon.

For menu options (and buttons):

Option Explicit
'
' Better if a global variable hack could be avoided
'  and the ToDo toggled directly
'  ToDo = Not ToDo
'
' False on startup
'  Applies in this module only
Dim mToDoFlag As Boolean

Sub ToDoToggle()
'
'  Office 2016 Help Files: Office Fluent User Interface Control Identifiers
'   https://www.microsoft.com/en-us/download/details.aspx?id=50745
'
'  Office 2013 Help Files: Office Fluent User Interface Control Identifiers
'   https://www.microsoft.com/en-us/download/details.aspx?id=36798
'
'  outlookexplorercontrols.xlsx

'Debug.Print mToDoFlag

If mToDoFlag = False Then
    ActiveExplorer.CommandBars.ExecuteMso ("ToDoBarOff")
Else
    ActiveExplorer.CommandBars.ExecuteMso ("ToDoBarShowAppointments")
    ActiveExplorer.CommandBars.ExecuteMso ("ToDoBarShowContactList")
    ActiveExplorer.CommandBars.ExecuteMso ("ToDoBarShowTaskList")
End If

mToDoFlag = Not mToDoFlag

End Sub

CodePudding user response:

There is no API to show/hide the To-Do Bar.

CodePudding user response:

There is no trivial way to hide the To-Do bar.

But you still can utilize command bars with their Execute method to call ribbon controls programmatically. Use the following sequence of calls to find the required control:

ActiveExplorer.CommandBars.FindControl(, id-for-the-command-to-run)

Then you may call the Execute method on that control.

Or just try using CommandBars.ExecuteMso method passing the idMso of the Off control. You may find ribbon control identifiers in the Office 2016 Help Files: Office Fluent User Interface Control Identifiers.

  • Related