Search code examples
c#winformsms-officeoffice-interop

How to change the color scheme of Word?


How can I change the color scheme of Microsoft Word programmatically using C#?

screenshot


Solution

  • const string OfficeCommonKey = @"Software\Microsoft\Office\14.0\Common";
                const string OfficeThemeValueName = "Theme";
                const int ThemeBlue = 1;
                const int ThemeSilver = 2;
                const int ThemeBlack = 3;
    
                using (RegistryKey key = Registry.CurrentUser.OpenSubKey(OfficeCommonKey, true))
                {
    
                    int theme = (int)key.GetValue(OfficeThemeValueName,1);
    
                    switch (theme)
                    {
                        case ThemeBlue:
                            //...
    
                            break;
                        case ThemeSilver:
                           // ...
    
                            break;
                        case ThemeBlack:
                           // ...
    
                            break;
                        default:
                           // ...
                            break;
                    }
                }