您可以尝试使用Redemption及其SafeRibbon对象:
'simulate a click on the "Assign Task" button of an active Inspector
set sInspector = CreateObject("Redemption.SafeInspector")
sInspector.Item = Application.ActiveInspector
set Ribbon = sInspector.Ribbon
oldActiveTab = Ribbon.ActiveTab
Ribbon.ActiveTab = "Task"
set Control = Ribbon.Controls("Assign Task")
Control.Execute
Ribbon.ActiveTab = oldActiveTab 'restore the active tab
编辑。在 C# 中,它将类似于以下内容(假设您将 Redemption 添加到项目引用中):
//simulate a click on the "Assign Task" button of an active Inspector
Redemption.SafeInspector sInspector = new Redemption.SafeInspector();
sInspector.Item = Application.ActiveInspector;
Redemption.SafeRibbon Ribbon = sInspector.Ribbon;
string oldActiveTab = Ribbon.ActiveTab;
Ribbon.ActiveTab = "Task";
Redemption.SafeRibbonControl Control = Ribbon.Controls.Item("Assign Task");
Control.Execute();
Ribbon.ActiveTab = oldActiveTab; //restore the active tab