0
如何以编程方式使用C#更改Microsoft Word的颜色方案?如何更改Word的配色方案?
如何以编程方式使用C#更改Microsoft Word的颜色方案?如何更改Word的配色方案?
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;
}
}
如果找你在Word 2010中,然后下面应该这样做,你需要传递的主题枚举之一。
ActiveDocument.DocumentTheme.ThemeColorScheme(msoThemeLight2)
在这里你可以找到A complete list of Word and Office ThemeColorIndex Enumeration Constants
这是假设他的使用或打算使用Office互操作。 –
@DaveZych它被标记为这样使其断言;) –
@LIUFA通过使用ActiveDocument.DocumentTheme.ThemeColorScheme.Colors(MsoThemeColorSchemeIndex.msoThemeDark1); colorSheme不会改变。我在哪里做错了? – user3788235