Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) With Application.CommandBars("cell") .Reset '重置右键菜单,以免因多次运行重复添加 ' .Controls("剪切(&T)").Delete '删除右键菜单中的剪切菜单 With .Controls.Add(Type:=msoControlPopup) '添加菜单 .Caption = "我的复制" '菜单名称 .BeginGroup = True '分组显示 With .Controls.Add(Type:=msoControlButton) '添加第一个二级菜单 .Caption = "复制上月暂估入库单" .FaceId = 19 '9590 '图标ID编号 .OnAction = "复制上月暂估入库单" '指定单击该菜单运行的VBA过程名 End With With .Controls.Add(Type:=msoControlButton) '添加第二个二级菜单 .Caption = "复制指定范围" .FaceId = 9591 .OnAction = "复制指定范围" End With With .Controls.Add(Type:=msoControlButton) '添加第三个子二级菜单 .Caption = "传送收料单到VFP" .FaceId = 9592 .OnAction = "传送收料单" End With End With End With
End Sub sub worksheet_deactivate() with application.commandbars("cell")
.rest
end with
end sub
|