'Outlook VBA to manage application options/advanced options
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. This needs to be an effective single-click, which means I need a macro. I don't want to restart Outlook as there are usually many things open.
Obviously you read this and thought "duh, just add it to the Quick Access Toolbar."
(For reference, on the left the option is present in the list of QAT commands, but not in the list of Ribbon commands, otherwise we could access it with ExecuteMso.)
Three reasons (beyond my fondness for automation):
- The button is disabled when you're not in the Calendar window. That's just inelegant.
- 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. :-)
- 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!
Edited to include reference to why ExecuteMso isn't the easy solution. Edited to include I don't want to restart Outlook
Solution 1:[1]
To disable reminder sound you need to set the below registry key to 0.
Registry key: PlaySound (REG_DWORD) to be set to 0.
Path: HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\options\Reminder
where 16.0 indicates the Outlook version.
Don't forget to restart Outlook to apply changes.
Solution 2:[2]
These settings can be overridden on the per appointment basis - you can simply set AppointmentItem
.ReminderPlaySound property to false using VBA.
Solution 3:[3]
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
Solution 4:[4]
As with most things in life, the answer is a workaround. In this case, it's AutoHotkey to press the keys for me (ALT F, T, down x 9, ALT P, Enter):
;WIN-O toggles the Outlook alarm sound setting
#o::
SetTitleMatchMode,2 ;inexact match
WinGetActiveTitle, MyWindowTitle
If WinActive(" - [email protected]") ;Poor way to "prove" we're in Outlook
{
;MsgBox, We're in Outlook
Send !ft{Down 9}
Send !p{Enter}
}
Return
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Eugene Astafiev |
Solution 2 | Dmitry Streblechenko |
Solution 3 | |
Solution 4 | Neman |