本文主要是介绍获取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;}
欢迎访问《 许阳的红泥屋 》
欢迎访问《 许阳的红泥屋 》
这篇关于获取Excel中Undo按钮的项目的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!