读书人

获取Excel中Undo旋钮的项目

发布时间: 2012-11-12 12:31:58 作者: rapoo

获取Excel中Undo按钮的项目

在VSTO中我们可以通过以下代码来获取Undo按钮的列表:

        private static Office.CommandBars getCommandBars()        {            return (Office.CommandBars)Globals.ThisWorkbook.Application.GetType().InvokeMember("CommandBars"                , System.Reflection.BindingFlags.GetProperty,                null,                Globals.ThisWorkbook.Application,                null,                System.Globalization.CultureInfo.InvariantCulture);        }        private static string getLastUndo()        {            string result = string.Empty;            Office.CommandBars oCommandBars = getCommandBars();            Office.CommandBar oCommandBar = oCommandBars["Standard"];            Office.CommandBarControl oCommandBarControl = (Office.CommandBarControl)oCommandBar.Controls[14];            MessageBox.Show(oCommandBarControl.Caption);            MessageBox.Show(oCommandBarControl.accChildCount.ToString());            try            {                if (oCommandBarControl is Office.CommandBarComboBox)                {                    Office.CommandBarComboBox ocbcb = (Office.CommandBarComboBox)oCommandBarControl;                    for (int i = 1; i < oCommandBarControl.accChildCount; i++)                    {                        MessageBox.Show(ocbcb.get_List(i));                    }                }                else                {                    MessageBox.Show("No");                }            }catch(Exception ex){                MessageBox.Show(ex.Message);            }            return result;        }




欢迎访问《许阳的红泥屋》


欢迎访问《许阳的红泥屋》

读书人网 >其他相关

热点推荐