user3788235
user3788235

Reputation: 31

How to change the color scheme of Word?

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

screenshot

Upvotes: 0

Views: 652

Answers (2)

user3788235
user3788235

Reputation: 31

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;
                }
            }

Upvotes: 1

Matas Vaitkevicius
Matas Vaitkevicius

Reputation: 61361

If you'r on Word 2010, then following should do it, you need to pass one of theme enums.

ActiveDocument.DocumentTheme.ThemeColorScheme(msoThemeLight2)

Here you can find A complete list of Word and Office ThemeColorIndex Enumeration Constants

Upvotes: 0

Related Questions