Sheet1.Shapes("tb").Copy '复制图标图片
With Application.CommandBars("Cell").Controls.Add(Type:=msoControlButton, before:=1, temporary:=True) '添加右键菜单
.Caption = "MyCommand" '设置标题
.OnAction = "msg" '指定宏
.PasteFace '黏贴标签
End With
End Sub
给你看一下 蓝色幻想的一个程序事例 ,代码放窗体的加载程序里面Sub 添加快捷菜单()
Dim mypup As CommandBar
Dim com As CommandBarButton
Dim x
删除命令
Set mypup = Application.CommandBars.Add(Name:="ABC", Position:=msoBarPopup)
For x = 1 To 4
Set com = mypup.Controls.Add
com.Caption = Choose(x, "兰色幻想", "小妖", "小佩", "展翅")
'这4个是加的按钮的名字, 可以改成你自己的, 比如复制粘贴等
com.FaceId = 17 + x
com.OnAction = "A"
'这句是指定的宏的名字, 可以改成你自己的宏, 比如复制 ,粘贴功能宏
Next x
End Sub
Sub 删除命令()
Application.CommandBars("ABC").Delete
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)