Home > OS >  Outlook VBA to manage application options/advanced options
Outlook VBA to manage application options/advanced options

Time:04-16

TL;DR: Need macro to quickly toggle File > Options > Advanced > Reminders > Play reminder sound setting

In certain meetings I need to keep Outlook running to get reminders, but don't want the reminder sound. Currently, it involves manually (i.e. like a chump) toggling the File > Options > Advanced > Reminders > Play reminder sound checkmark. Obviously this needs to be a single-click, which means I need a macro.

Obviously you read this and thought "duh, just add it to the Quick Access Toolbar." enter image description here

Three reasons (beyond my fondness for automation):

  1. The button is disabled when you're not in the Calendar window. That's just inelegant.

enter image description here

  1. When I click the button, Outlook instantly crashes and I lose everything that wasn't saved. (No, autosave isn't sufficient or functioning. That's a different problem.) That's not exactly what I had in mind. :-)
  2. Understanding how to access Outlook settings with VBA opens a whole new world of possibilities.

This Microsoft article series starting at https://docs.microsoft.com/en-us/office/vba/outlook/concepts/getting-started/automating-outlook-from-a-visual-basic-application is about automating Outlook user tasks, like making a calendar appointment. That's not what I want - I want to manage Outlook's options.

There seem to be some discussions about COM add-ins as one method, but that appears beyond me. The effort to learn COM add-ins is currently out of line with manual effort to achieve the desired goal.

I have some limited Outlook VBA experience but am reasonably comfortable with VBA in Word, Excel, etc. I'm not confident I understand the object model or how to address stuff, but can hack my way through examples, if you'd be so kind.

Noting if Outlook just worked as intended, I'd have used the QAT button approach.

Thanks!

CodePudding user response:

These settings can be overridden on the per appointment basis - you can simply set AppointmentItem.ReminderPlaySound property to false using VBA.

CodePudding user response:

Simulate a button press with ExecuteMso.
https://docs.microsoft.com/en-us/office/vba/api/Office.CommandBars.ExecuteMso

Hover over the button where you would add it to the ribbon/QAT. See text in brackets at the end.
Are the command codes for ExecuteMso documented?

Private Sub ExecuteMso_TextInBrackets()

    ' https://docs.microsoft.com/en-us/office/vba/api/Office.CommandBars.ExecuteMso
    ' https://stackoverflow.com/questions/25610998/are-the-command-codes-for-executemso-documented
    
    Dim oAppt As Object
    Set oAppt = ActiveInspector.CurrentItem
    Debug.Print oAppt.subject
    
    ActiveInspector.CommandBars.ExecuteMso ("TextInBrackets")
    
End Sub
  • Related