2014-07-02 67 views

回答

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

如果找你在Word 2010中,然后下面应该这样做,你需要传递的主题枚举之一。

ActiveDocument.DocumentTheme.ThemeColorScheme(msoThemeLight2) 

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

+0

这是假设他的使用或打算使用Office互操作。 –

+2

@DaveZych它被标记为这样使其断言;) –

+0

@LIUFA通过使用ActiveDocument.DocumentTheme.ThemeColorScheme.Colors(MsoThemeColorSchemeIndex.msoThemeDark1); colorSheme不会改变。我在哪里做错了? – user3788235