2
在一個excel COM插件中我需要訪問pageSetup屬性。但是如果excel中的編輯模式是活動的,我會得到一個異常。Excel vsto結束編輯模式
我可以檢查,如果編輯模式是與此代碼的主動:
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屬性?