Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How can I change the colorsheme of Microsoft Word programmatically using C#?
I'm on Word 2010, I pass one of theme enums:
C#
ActiveDocument.DocumentTheme.ThemeColorScheme.Colors(MsoThemeColorSchemeIndex.ms‌​oThemeDark1);

But colorSheme doesnot change.
Where am I doing wrong?
Posted
Comments
ZurdoDev 5-Jul-14 21:23pm    
Record a macro doing what you want and then you can see the code.

1 solution

C#
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;
                    }
                }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900