我写了一个类来检测当前的 Excel 主题是什么。
获取 Excel 当前办公主题:
//Declaration
string officeVersion;
int themeCode;
// Get Office Version first
officeVersion = "16.0";
// Goto the Registry Current Version
RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Office\" + officeVersion + @"\Common");
// Get Stored Theme
themeCode = (int)rk.GetValue("UI Theme", GlobalVar.COLORFUL);
Run Code Online (Sandbox Code Playgroud)
然后根据 的值themeCode,我可以确定当前的 Excel 主题是什么:
// Theme Constants
public const int COLORFUL = 0;
public const int DARKGREY = 3;
public const int BLACK = 4;
public const int WHITE = 5;
Run Code Online (Sandbox Code Playgroud)
我的问题:
- 如何检测用户在 Excel 运行期间何时从Excel …