VBA中怎样生成2级命令菜单
PrivateSubWorkbook_Open()CallAutoOpenEndSub模块中:DimcbarAsCommandBarDimcCtrolAsCommandB...
Private Sub Workbook_Open()
Call AutoOpen
End Sub
模块中:
Dim cbar As CommandBar
Dim cCtrol As CommandBarControl
Dim cmd As CommandBarButton
Sub AutoOpen()
Set cbar = Application.CommandBars.Add(Name:="CAL-Lab", Position:=msoBarTop, MenuBar:=False, Temporary:=True)
Set cCtrol = cbar.Controls.Add(Type:=msoControlPopup)
With cCtrol
.caption = "CHeck"
Set cmd = cCtrol.Controls.Add(1)
With cmd
.Style = msoButtonIconAndCaption
.caption = "SetDMMVoltage"
.FaceId = 0
.Tag = "d2"
.onAction = "SetVoltage"
End With
End With
End Sub
现在想实现在.caption = "SetDMMVoltage"的菜单下边在生成一个2级菜单.caption = "SetDCVoltage"和caption = "SetACVoltage"---请高手指点。。分数可以+到很好哈。。。 展开
Call AutoOpen
End Sub
模块中:
Dim cbar As CommandBar
Dim cCtrol As CommandBarControl
Dim cmd As CommandBarButton
Sub AutoOpen()
Set cbar = Application.CommandBars.Add(Name:="CAL-Lab", Position:=msoBarTop, MenuBar:=False, Temporary:=True)
Set cCtrol = cbar.Controls.Add(Type:=msoControlPopup)
With cCtrol
.caption = "CHeck"
Set cmd = cCtrol.Controls.Add(1)
With cmd
.Style = msoButtonIconAndCaption
.caption = "SetDMMVoltage"
.FaceId = 0
.Tag = "d2"
.onAction = "SetVoltage"
End With
End With
End Sub
现在想实现在.caption = "SetDMMVoltage"的菜单下边在生成一个2级菜单.caption = "SetDCVoltage"和caption = "SetACVoltage"---请高手指点。。分数可以+到很好哈。。。 展开
2个回答
展开全部
整整1个小时裤哪销,通过研究“胡游List”工具栏得到启发
测试通过
模块中:
Dim cbar As CommandBar
Dim cCtrol As CommandBarControl
Dim cmd1 As CommandBarControl
Dim cmd As CommandBarButton
Sub AutoOpen()
Set cbar = Application.CommandBars.Add(Name:="CAL-Lab7", Position:=msoBarTop, MenuBar:=False, Temporary:=True)
Set cCtrol = cbar.Controls.Add(Type:=msoControlPopup)
With cCtrol
.Caption = "CHeck"
End With
Set cmd1 = cCtrol.Controls.Add(Type:=msoControlPopup)
With cmd1
.Caption = "缓凳测试"
End With
Set cmd = cmd1.Controls.Add(1)
With cmd
.Style = msoButtonIconAndCaption
.Caption = "SetDMMVoltage"
.FaceId = 0
.Tag = "d2"
.OnAction = "SetVoltage"
End With
End Sub
哈哈,记得加分哦!
测试通过
模块中:
Dim cbar As CommandBar
Dim cCtrol As CommandBarControl
Dim cmd1 As CommandBarControl
Dim cmd As CommandBarButton
Sub AutoOpen()
Set cbar = Application.CommandBars.Add(Name:="CAL-Lab7", Position:=msoBarTop, MenuBar:=False, Temporary:=True)
Set cCtrol = cbar.Controls.Add(Type:=msoControlPopup)
With cCtrol
.Caption = "CHeck"
End With
Set cmd1 = cCtrol.Controls.Add(Type:=msoControlPopup)
With cmd1
.Caption = "缓凳测试"
End With
Set cmd = cmd1.Controls.Add(1)
With cmd
.Style = msoButtonIconAndCaption
.Caption = "SetDMMVoltage"
.FaceId = 0
.Tag = "d2"
.OnAction = "SetVoltage"
End With
End Sub
哈哈,记得加分哦!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询