VBA添加菜单

发布时间:2020-05-21 12:43:33 作者:xiweicheng1987
来源:网络 阅读:803

 

 
Sub CreateMenu()
 
    Dim menuBar As CommandBar
    Set menuBar = Application.CommandBars("Worksheet Menu Bar")
    
    menuBar.Reset
    Dim menu As CommandBarPopup
    Set menu = menuBar.Controls.Add(Type:=msoControlPopup, temporary:=True)
    menu.Caption = "Tools"
    
    Dim menuItem As CommandBarButton
    Set menuItem = menu.Controls.Add(Type:=msoControlButton, temporary:=True)
    menuItem.Caption = "SheetCompare"
    menuItem.OnAction = "CompareHandle"
    
    Dim menuItem2 As CommandBarButton
    Set menuItem2 = menu.Controls.Add(Type:=msoControlButton, temporary:=True)
    menuItem2.Caption = "ExportSheetAsTxt"
    menuItem2.OnAction = "ExportSheetAsTxt"
    
    Dim menuItem5 As CommandBarButton
    Set menuItem5 = menu.Controls.Add(Type:=msoControlButton, temporary:=True)
    menuItem5.Caption = "SheetsCompare"
    menuItem5.OnAction = "SheetsCompare"
    
    Dim menuItem3 As CommandBarButton
    Set menuItem3 = menu.Controls.Add(Type:=msoControlButton, temporary:=True)
    menuItem3.Caption = "CreateInsertSQL"
    menuItem3.OnAction = "SqlInsert"
    
    Dim menuItem4 As CommandBarButton
    Set menuItem4 = menu.Controls.Add(Type:=msoControlButton, temporary:=True)
    menuItem4.Caption = "CreateDeleteSQL"
    menuItem4.OnAction = "SqlDelete"
 
End Sub
 
推荐阅读:
  1. Excel VBA代码无法保存
  2. VBA 自动关闭 弹出的对话框 + VBA错误捕捉

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

vba添加菜单

上一篇:"rel=nofollow"属性简介

下一篇:CentOS7删除/boot/initramfsxxx.img并尝试光盘救援模式修复

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》