vsto 检测是否在编辑状态或者光标闪动

object m = Type.Missing;
const int MENU_ITEM_TYPE = 1;
const int NEW_MENU = 18;

CommandBarControl oNewMenu =
ExcelGlobals.Application.CommandBars["Worksheet Menu Bar"].FindControl(
MENU_ITEM_TYPE, //the type of item to look for
NEW_MENU, //the item to look for
m, //the tag property (in this case missing)
m, //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)
{
if (!oNewMenu.Enabled)
{
MessageBox.Show("当前文档有光标在闪动,请取消光标闪动");
return;
}
}

你可能感兴趣的:(vsto 检测是否在编辑状态或者光标闪动)