请看我写的如下代码:<br>// 创建WordApplication对象<br> WordApp:=CreateComObject(CLASS_Application) as _Application;<br>procedure VisibleMemu(X,y:Integer;FWordApp: _Application;Visibled:Boolean);<br>var Bak:CommandBar;<br> Bak1:CommandBarPopup;<br> i:Integer;<br>begin<br> for i:=1 to FWordApp.CommandBars.Count do<br> if UpperCase(FWordApp.CommandBars.Item.Name)='MENU BAR' then<br> begin<br> Bak:=FWordApp.CommandBars.Item;<br> Break;<br> end;<br> Bak1:=Bak.Controls.Item[x] As CommandBarPopup;<br> if y<=0 then<br> Bak1.Visible:=False<br> else<br> Bak1.Controls.Item[y].Visible:=Visibled;<br>end;<br><br>Function ModifyMemuCaption(X,y:Integer;FWordApp: _Application;NewCaption:String):String;<br>var Bak:CommandBar;<br> Bak1:CommandBarPopup;<br> i:Integer;<br>begin<br> for i:=1 to FWordApp.CommandBars.Count do<br> if UpperCase(FWordApp.CommandBars.Item.Name)='MENU BAR' then<br> begin<br> Bak:=FWordApp.CommandBars.Item;<br> Break;<br> end;<br> Bak1:=Bak.Controls.Item[x] As CommandBarPopup;<br> result:=Bak1.Controls.Item[y].Caption;<br> Bak1.Controls.Item[y].Caption:=NewCaption;<br>end;<br><br>procedure AddMemuItems(X,y:Integer;FWordApp: _Application;NewCaption:String);<br>var Bak:CommandBar;<br> Bak1:CommandBarPopup;<br> i:Integer;<br> Type1, Id1, Parameter1, Before1, Temporary1:Variant;<br>begin<br> for i:=1 to FWordApp.CommandBars.Count do<br> if UpperCase(FWordApp.CommandBars.Item.Name)='MENU BAR' then<br> begin<br> Bak:=FWordApp.CommandBars.Item;<br> Break;<br> end;<br> Bak1:=Bak.Controls.Item[Bak.Controls.Count] As CommandBarPopup;<br> if x<=0 then<br> begin<br> Type1:=msoControlDropdown;<br> Id1:=Bak1.Id+1;<br> Parameter1:=Unassigned;<br> Before1:=y;<br> Temporary1:=True;<br> with Bak.Controls.Add(Type1,Id1,Parameter1,Before1,Temporary1) do<br><br> Caption:=NewCaption;<br><br> end<br> else<br> begin<br> Parameter1:='';<br> Temporary1:=True;<br> Id1:=Bak.Controls.Item[Bak.Controls.Count].ID+1;<br> Bak1:=Bak.Controls.Item[x] As CommandBarPopup;<br> with Bak1.Controls.Add(msoControlPopup,Id1,Parameter1,y,Temporary1) do<br> Caption:=NewCaption;<br> end;<br><br> //result:=Bak1.Controls.Item[y].Caption;<br> //Bak1.Controls.Item[y].Caption:=Caption;<br>end;