在WROD中,有两种方法制作下拉菜单,一是自定义方式,可以保存在NORMAL.DOT中,或者新的模板中,也可以保存在活动文档中.工具/自定义/拖出相应的菜单项(自定义对话框/命令/新菜单),再新增下拉的菜单项,可参:http://club.excelhome.net/viewthread.php?tid=65559的样式,主要是自定义. 第二种是用代码,则先要新建一个工具栏(容器),然后再新增工具栏的控件按钮),如: '* +++++++++++++++++++++++++++++++++++++++ '* Created By 守柔(ShouRou)@ExcelHome 2005-1-7 10:13:36 '仅测试于System: Windows NT Word: 10.0 Language: 2052 '^The Code CopyIn [ThisDocument-ThisDocument]^' '* -------------------------------------------------------------------------- Sub ExampleMenuAdd()
Dim MyCom As CommandBarControl, MyControl1 As CommandBarButton, MyControl2 As CommandBarControl
On Error Resume Next
Application.CommandBars("Menu Bar").Controls("MyCom").Delete '预防性删除
'新增一个菜单(在原来的菜单的最后一个位置)
Set MyCom = Application.CommandBars("Menu Bar").Controls.Add(Type:=msoControlPopup)
With MyCom
.Caption = "MyCom" '设置名称
Set MyControl1 = .Controls.Add
With MyControl1
.Caption = "MyControl1" '设置名称
.OnAction = "Sub1" '执行指定的过程名
.FaceId = 100 '指定FACEID号
End With
Set MyControl2 = .Controls.Add
With MyControl2
.Caption = "MyControl2"
.OnAction = "Sub2"
.FaceId = 2
End With
End With
End Sub
'----------------------
Sub Sub1()
MsgBox "This is a test!"
End Sub
'----------------------
Sub Sub2()
MsgBox "This is a test!"
End Sub
'---------------------- |