如何从C#VSTO检查PowerPoint设计模式中的标尺是否可见/活动?
我在PowerPoint对象模型中搜索了几个小时。我是否错过了明显的,或者是否有一个标志,指明标尺是否可见?
是否还有其他变通方法可以检查标尺是否打开?(我不需要调整标尺的可见性,只需读取值)。
作为一种解决方法,我尝试扩展功能区并读取定义为idMso =" ViewRulerPowerPoint"
的复选框的值XML
<?xml version="1.0" encoding="UTF-8"?>
<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<commands>
<command idMso="ViewRulerPowerPoint" onAction="OnRulerAction" />
</commands>
</customUI>
回调
public void OnRulerAction(Microsoft.Office.Core.IRibbonControl control, bool pressed)
{
Debug.Print("Checkbox pressed");
}
但我收到以下错误消息:
Callback signature mismatch: OnRulerAction
我已经尝试了几个小时来找到合适的回叫签名,但我的尝试都没有成功。
答案 0 :(得分:3)
在VBA中,您可以使用以下命令检查复选框是否已选中,该命令将返回True
或False
:
Application.CommandBars.GetPressedMso("ViewRulerPowerPoint")
在C#VSTO加载项中,您可以将此代码重写为:
Globals.ThisAddIn.Application.CommandBars.GetPressedMso("ViewRulerPowerPoint")