Cookies on this site

We would like to use cookies to understand how the site is used and to measure our campaigns. Nothing is set until you choose, and you can change your mind at any time from “Cookie settings” at the foot of every page. Privacy policy

Contact UsContact Us

Resources / Blogs

Microsoft 365 & Azure

Microsoft Office – Theme Change Event via VSTO Add-In

Office doesn't have a theme change event in their C# VSTO API, so in order to detect the theme change, we need to monitor the registry key UI Theme.

· · 1 min read

Microsoft Azure

Microsoft Office doesn’t have a theme change event in their VSTO API, so in order to detect the theme change, we need to monitor the registry key “UI Theme”.
The key can be found in the following registry path:

For Office 2013: HKEY_CURRENT_USERSOFTWAREMicrosoftOffice15.0Common
For Office 2016: HKEY_CURRENT_USERSOFTWAREMicrosoftOffice16.0Common

The value is a REG_DWORD and its range can be from 0 to 3 depending on the version of outlook installed 0 being the default theme.
If user haven’t changed the theme from start, the Key value pair might not be present.
Themes available for Office 2013
• White = 0
• Light Gray = 1
• Dark Gray = 2
Themes available for Office 2016
• Colorful = 0
• Dark Gray = 1
• Black = 2
• White = 3

To monitor any change in the value, we will use “ManagementEventWatcher” class

public void StartThemeWatcher()
{
var currentUser = WindowsIdentity.GetCurrent();
WqlEventQuery query = new WqlEventQuery(string.Format(
"SELECT * FROM RegistryValueChangeEvent WHERE " +
"Hive = 'HKEY_USERS'" +
@"AND KeyPath = '{0}SOFTWAREMicrosoftOffice15.0Common' AND ValueName='UI Theme'", currentUser.User.Value));
ManagementEventWatcher watcher = new ManagementEventWatcher(query);
watcher.EventArrived += Watcher_EventArrived;
watcher.Start();
}
private void Watcher_EventArrived(object sender, EventArrivedEventArgs e)
{
try
{
using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWAREMicrosoftOffice15.0Common"))
{
if (key != null)
{
object objectValue = key.GetValue("UI Theme");
if (objectValue != null)
{
int value = (int)objectValue;
MessageBox.Show(value.ToString());
}
}
}
}
catch (Exception ex)
{
}
}

In case you need to detect the current outlook version in VSTO, this might be helpful
Globals.AddinName.Application.Version

The solution for theme change detection is a bit tricky, but it will serve the purpose.

← All articles

Case studies

Microsoft Consulting in practice

Client names are withheld. We are happy to share details on a call.

All case studies
  • Delivered

    600k files, < 3 days

    Document management

    Microsoft

    600,000 documents moved from ImageRight to SharePoint in under three days

    A one-file-at-a-time script would have needed about 22 days of continuous running. We rebuilt the migration around a SQL work queue with parallel uploads, automatic retries and crash recovery, and it finished unattended in under three days.

    • 1,125 → 8,314 files per hour
    • Under 3 days instead of about 22
  • Product

    Every prompt screened

    Any industry on Microsoft 365

    Microsoft

    AI activity and data posture for Microsoft 365

    Sentinel watches Copilot and Copilot Studio agents in a Microsoft 365 tenant. It logs prompts and tool calls, scores each agent's risk, flags oversharing and stale access, and screens prompts for injection attempts with a classifier that runs locally at no per-call cost.

    • Every agent prompt screened
    • Runs inside the customer's own Azure tenant
  • In production

    Hours → minutes

    Food manufacturing

    AI Consulting

    Document intake agent for a national food cooperative

    A Copilot Studio agent reads certificates of analysis as they arrive in the quality team's inbox, extracts 14 fields with AI Builder, checks them, files the PDF in SharePoint and posts a summary in Teams. Fields it is unsure about go to a person instead of being guessed.

    • Hours of daily filing down to minutes
    • 14 fields per document, validated

Keep reading

All Microsoft 365 & Azure articles

Planning something on Microsoft 365 or Azure?

Talk to the engineers who write these articles. We will look at your tenant and tell you what to do first.