ExcelTip.Net留存知识帖 ---【注:附件之前被网盘供应商清空后,现已修复-现已修复-现已修复为本地下载!】
现在位置:首页 > 我的酷贴 > Excel VBA > 三级右键菜单

三级右键菜单

作者:绿色风 分类: 时间:2022-08-18 浏览:80
楼主
佛山小老鼠
  1. Sub Test()
  2. On Error Resume Next
  3. Application.CommandBars("cell").Controls("佛山小老鼠").Delete
  4. Set cb = Application.CommandBars("cell").Controls.Add(Type:=msoControlPopup, before:=1)
  5. With cb
  6.     .Caption = "佛山小老鼠"
  7.     With .Controls.Add(Type:=msoControlButton, before:=1)
  8.         .Caption = "签名"
  9.         .FaceId = 31
  10.         .OnAction = "签名2"
  11.     End With
  12.     With .Controls.Add(Type:=msoControlButton, before:=2)
  13.          .Caption = "复位所有右键"
  14.          .FaceId = 35
  15.          .OnAction = "ResetRight2"
  16.     End With
  17.     With .Controls.Add(Type:=msoControlPopup, before:=3)
  18.       .Caption = "日期&时间"
  19.         With .Controls.Add(Type:=msoControlButton, before:=1)
  20.               .Caption = "日期"
  21.               .FaceId = 50
  22.               .OnAction = "日期"
  23.         End With
  24.         With .Controls.Add(Type:=msoControlButton, before:=2)
  25.             .Caption = "时间"
  26.            .FaceId = 33
  27.            .OnAction = "时间"
  28.         End With
  29.     End With
  30. End With
  31. End Sub

  32. Sub ResetRight2()
  33.     Application.CommandBars("cell").Reset
  34. End Sub

  35. Sub 签名2()
  36.     Selection = "佛山小老鼠"
  37. End Sub

  38. Sub 日期()
  39.     Selection = Format(Date, "mm-dd")
  40. End Sub

  41. Sub 时间()
  42.     Selection = Format(Now, "hh:mm")
  43. End Sub

2楼
biaotiger1
为方便测试代码,上传一个图片供参考。2012-2-25 0-59-54.jpg
 
3楼
水星钓鱼
署名作者写的不规范

免责声明

有感于原ExcelTip.Net留存知识的价值及部分知识具有的时间限定性因素, 经与ExcelTip.Net站长Apolloh商议并征得其同意, 现将原属ExcelTip.Net的知识帖采集资料于本站点进行展示, 供有需要的人士查询使用,也慰缅曾经的论坛时代。 所示各个帖子的原作者如对版权有异议, 可与本人沟通提出,或于本站点留言,我们会尽快处理。 在此,感谢ExcelTip.Net站长Apolloh的支持,感谢本站点所有人**绿色风(QQ:79664738)**的支持与奉献,特此鸣谢!
------本人网名**KevinChengCW(QQ:1210618015)**原ExcelTip.Net总版主之一

评论列表
sitemap