//创建菜单项 try if WordApp.CommandBars.ActiveMenuBar.Enabled then begin with WordApp.CommandBars.ActiveMenuBar do begin for I := 1 to Controls.Count do if Controls.Item.Caption = 'test' then Controls.Item.Delete(True); NewMenu:= Controls.Add(msoControlpopup, EmptyParam, EmptyParam, EmptyParam, True) as CommandBarPopup; //创建menuitem NewMenu.Set_Caption('test'); //创建打开痕迹保留菜单 with NewMenu do begin NewMarkMenu := Controls.Add(msoControlButton, EmptyParam, EmptyParam, EmptyParam, True) as CommandBarButton; NewMarkMenu.Set_Caption('打开痕迹保留'); NewMarkMenu.Set_OnAction('MarkSave'); //将一个宏赋值给这个ITEM NewMarkMenu.Set_State(msoButtonDown); end; //创建保存菜单 NewMenu. with NewMenu do begin NewSaveWdsl := Controls.Add(msoControlButton, EmptyParam, EmptyParam, EmptyParam, True) as CommandBarButton; NewSaveWdsl.Set_Caption('保存文档'); NewSaveWdsl.Set_OnAction('SaveWdsl'); //将一个宏赋值给这个ITEM NewSaveWdsl.Set_State(msoButtonUp); NewSaveWdsl.Set_Parameter(pWebServiceURL); end; end; end; except ShowMessage('创建菜单失败'); Abort; end;现在是用VBA里面的宏来响应点击事件的 但是VBA的宏提交不好用 所以现在希望能执行delphi代码