如何更改Word的配色方案?

时间:2014-07-02 14:15:22

标签: c# winforms ms-office office-interop

如何使用C#以编程方式更改Microsoft Word的配色方案?

screenshot

2 个答案:

答案 0 :(得分:0)

如果您使用的是Word 2010,那么应该执行以下操作,您需要传递一个主题枚举。

ActiveDocument.DocumentTheme.ThemeColorScheme(msoThemeLight2)

您可以在这里找到A complete list of Word and Office ThemeColorIndex Enumeration Constants

答案 1 :(得分:0)

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