小编Tsi*_*ina的帖子

C# Visual Studio Excel 加载项:如何检测 Excel Office 主题更改?

我写了一个类来检测当前的 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 …

c# excel vba visual-studio excel-addins

5
推荐指数
1
解决办法
213
查看次数

标签 统计

c# ×1

excel ×1

excel-addins ×1

vba ×1

visual-studio ×1