Excel vba 利用模块来创建自定义菜单的编码,到底哪儿错了?求大神指点!急急急!!!
DimmymenuobjectAsCommandBarPopupDimmymenuitemAsObjectDimmysubmenuitemAsObjectPublicSu...
Dim mymenuobject As CommandBarPopup
Dim mymenuitem As Object
Dim mysubmenuitem As Object
Public Sub 自定义菜单()
On Error Resume Next
Application.CommandBars(1).Controls("销售管理子系统").Delete
Set mymenuobject = Application.CommandBars(1). _
Controls.Add(Type:=msoControlPopup, before:=11, Temporary:=True)
With mymenuobject
.Caption = "销售管理子系统"
.Width = 150
.BeginGroup = True
End With
Call 主菜单("注册")
Call 子菜单("登录")
Call 子菜单("注销")
Call 主菜单("系统管理")
Call 子菜单("修改密码")
Call 主菜单("登记")
Call 子菜单("销售记录")
Call 子菜单("退货记录")
Call 主菜单("查询")
Call 子菜单("销售记录")
Call 子菜单("退货记录")
Call 子菜单("库存")
Call 主菜单("数据分析")
Call 子菜单("分类汇总")
Call 子菜单("比较分析")
Call 主菜单("输出打印")
Call 子菜单("数据输出")
Call 子菜单("打印")
Call 主菜单("数据备份及恢复")
Call 子菜单("数据备份")
Call 子菜单("数据恢复")
End Sub
Public Sub 主菜单(mycaption As String)
Set mymenuitem = mymenuobject.Controls.Add(Type:=msoControlPopup)
With mymenuitem
.Caption = mycaption
.BeginGroup = True
End With
End Sub
Public Sub 子菜单(mycaption As String, myonaction As String)
Set mysubmenuitem = .Controls.Add(Type:=msoControlButton)
With mysubmenuitem
.Caption = mycaption
.onaction = myonaction
.BeginGroup = True
End With
End Sub
调试的时候系统弹出“参数不可选”的对话框,对象是前面的“call 子菜单”,这到底是因为什么? 展开
Dim mymenuitem As Object
Dim mysubmenuitem As Object
Public Sub 自定义菜单()
On Error Resume Next
Application.CommandBars(1).Controls("销售管理子系统").Delete
Set mymenuobject = Application.CommandBars(1). _
Controls.Add(Type:=msoControlPopup, before:=11, Temporary:=True)
With mymenuobject
.Caption = "销售管理子系统"
.Width = 150
.BeginGroup = True
End With
Call 主菜单("注册")
Call 子菜单("登录")
Call 子菜单("注销")
Call 主菜单("系统管理")
Call 子菜单("修改密码")
Call 主菜单("登记")
Call 子菜单("销售记录")
Call 子菜单("退货记录")
Call 主菜单("查询")
Call 子菜单("销售记录")
Call 子菜单("退货记录")
Call 子菜单("库存")
Call 主菜单("数据分析")
Call 子菜单("分类汇总")
Call 子菜单("比较分析")
Call 主菜单("输出打印")
Call 子菜单("数据输出")
Call 子菜单("打印")
Call 主菜单("数据备份及恢复")
Call 子菜单("数据备份")
Call 子菜单("数据恢复")
End Sub
Public Sub 主菜单(mycaption As String)
Set mymenuitem = mymenuobject.Controls.Add(Type:=msoControlPopup)
With mymenuitem
.Caption = mycaption
.BeginGroup = True
End With
End Sub
Public Sub 子菜单(mycaption As String, myonaction As String)
Set mysubmenuitem = .Controls.Add(Type:=msoControlButton)
With mysubmenuitem
.Caption = mycaption
.onaction = myonaction
.BeginGroup = True
End With
End Sub
调试的时候系统弹出“参数不可选”的对话框,对象是前面的“call 子菜单”,这到底是因为什么? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询