我编写了一个类,可以检测当前Excel主题。
获取Excel当前Office主题:
//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);
根据themeCode
的值,我可以确定当前的Excel主题:
// Theme Constants
public const int COLORFUL = 0;
public const int DARKGREY = 3;
public const int BLACK = 4;
public const int WHITE = 5;
我的问题:
- 在Excel运行期间,如何检测用户是否从 Excel选项更改了Office主题?
- 换句话说,当用户从Excel选项编辑任何内容时,是否有任何Excel事件会被触发?
- 请问如何检测/捕获该事件?
我已经使用过进程监视器(Process Monitor)并获取了存储主题的注册表键的位置。但是我不能不断地检查注册表,我希望能够检测到用户点击更多命令\Excel选项的事件(如果该事件可检测)。
欢迎回答和建议。提前致谢!