【发布时间】:2014-04-04 14:56:55
【问题描述】:
在 excel COM 插件中,我需要访问 pageSetup 属性。但如果 excel 中的编辑模式处于活动状态,我会遇到异常。
我可以使用此代码检查编辑模式是否处于活动状态:
CommandBarControl oNewMenu = excelApp.CommandBars["Worksheet Menu Bar"].FindControl(
1, //the type of item to look for
18, //the item to look for
refmissing, //the tag property (in this case missing)
refmissing, //the visible property (in this case missing)
true); //we want to look for it recursively so the last argument should be true.
if ( oNewMenu != null )
{
// edit mode = true
if (!oNewMenu.Enabled) {
}
}
我找到了一些退出编辑模式的解决方案,但没有奏效:
SendKeys.Flush();
excelApplication.SendKeys("{ENTER}");
如何退出编辑模式以便编写 pageSetup 属性?
【问题讨论】:
-
据 Microsoft Office 可扩展性团队的项目经理 this answer,目前不支持此功能。