Reputation: 31
How can I change the color scheme of Microsoft Word programmatically using C#?
Upvotes: 0
Views: 652
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
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