vba窗口中显示右键
2014-03-23 14:27
591 查看
Dim flag
Private Sub TextBox1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
On Error Resume Next
If Button = 2 And Not flag Then
On Error Resume Next
Application.CommandBars("dddd").Delete
Application.CommandBars.Add "dddd", msoBarPopup, False, True
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(1).Caption = "剪切"
Application.CommandBars("dddd").Controls(1).FaceId = 21
Application.CommandBars("dddd").Controls(1).OnAction = "cut2"
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(2).Caption = "复制"
Application.CommandBars("dddd").Controls(2).FaceId = 19
Application.CommandBars("dddd").Controls(2).OnAction = "copy2"
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(3).Caption = "粘贴"
Application.CommandBars("dddd").Controls(3).FaceId = 22
Application.CommandBars("dddd").Controls(3).OnAction = "pt"
Application.CommandBars("dddd").showpopup
End If
flag = Not flag
End Sub
Private Sub TextBox2_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
On Error Resume Next
If Button = 2 And Not flag Then
On Error Resume Next
Application.CommandBars("dddd").Delete
Application.CommandBars.Add "dddd", msoBarPopup, False, True
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(1).Caption = "剪切"
Application.CommandBars("dddd").Controls(1).FaceId = 21
Application.CommandBars("dddd").Controls(1).OnAction = "cut2"
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(2).Caption = "复制"
Application.CommandBars("dddd").Controls(2).FaceId = 19
Application.CommandBars("dddd").Controls(2).OnAction = "copy2"
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(3).Caption = "粘贴"
Application.CommandBars("dddd").Controls(3).FaceId = 22
Application.CommandBars("dddd").Controls(3).OnAction = "pt"
Application.CommandBars("dddd").showpopup
End If
flag = Not flag
End Sub
Private Sub TextBox3_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
On Error Resume Next
If Button = 2 And Not flag Then
On Error Resume Next
Application.CommandBars("dddd").Delete
Application.CommandBars.Add "dddd", msoBarPopup, False, True
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(1).Caption = "剪切"
Application.CommandBars("dddd").Controls(1).FaceId = 21
Application.CommandBars("dddd").Controls(1).OnAction = "cut2"
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(2).Caption = "复制"
Application.CommandBars("dddd").Controls(2).FaceId = 19
Application.CommandBars("dddd").Controls(2).OnAction = "copy2"
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(3).Caption = "粘贴"
Application.CommandBars("dddd").Controls(3).FaceId = 22
Application.CommandBars("dddd").Controls(3).OnAction = "pt"
Application.CommandBars("dddd").showpopup
End If
flag = Not flag
End Sub
Private Sub UserForm_Activate()
flag = False
End Sub
Sub copy2()
Application.SendKeys "^C"
End Sub
Sub cut2()
Application.SendKeys "^X"
End Sub
Sub pt()
Application.SendKeys "^V"
End Sub
Private Sub TextBox1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
On Error Resume Next
If Button = 2 And Not flag Then
On Error Resume Next
Application.CommandBars("dddd").Delete
Application.CommandBars.Add "dddd", msoBarPopup, False, True
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(1).Caption = "剪切"
Application.CommandBars("dddd").Controls(1).FaceId = 21
Application.CommandBars("dddd").Controls(1).OnAction = "cut2"
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(2).Caption = "复制"
Application.CommandBars("dddd").Controls(2).FaceId = 19
Application.CommandBars("dddd").Controls(2).OnAction = "copy2"
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(3).Caption = "粘贴"
Application.CommandBars("dddd").Controls(3).FaceId = 22
Application.CommandBars("dddd").Controls(3).OnAction = "pt"
Application.CommandBars("dddd").showpopup
End If
flag = Not flag
End Sub
Private Sub TextBox2_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
On Error Resume Next
If Button = 2 And Not flag Then
On Error Resume Next
Application.CommandBars("dddd").Delete
Application.CommandBars.Add "dddd", msoBarPopup, False, True
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(1).Caption = "剪切"
Application.CommandBars("dddd").Controls(1).FaceId = 21
Application.CommandBars("dddd").Controls(1).OnAction = "cut2"
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(2).Caption = "复制"
Application.CommandBars("dddd").Controls(2).FaceId = 19
Application.CommandBars("dddd").Controls(2).OnAction = "copy2"
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(3).Caption = "粘贴"
Application.CommandBars("dddd").Controls(3).FaceId = 22
Application.CommandBars("dddd").Controls(3).OnAction = "pt"
Application.CommandBars("dddd").showpopup
End If
flag = Not flag
End Sub
Private Sub TextBox3_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
On Error Resume Next
If Button = 2 And Not flag Then
On Error Resume Next
Application.CommandBars("dddd").Delete
Application.CommandBars.Add "dddd", msoBarPopup, False, True
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(1).Caption = "剪切"
Application.CommandBars("dddd").Controls(1).FaceId = 21
Application.CommandBars("dddd").Controls(1).OnAction = "cut2"
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(2).Caption = "复制"
Application.CommandBars("dddd").Controls(2).FaceId = 19
Application.CommandBars("dddd").Controls(2).OnAction = "copy2"
Application.CommandBars("dddd").Controls.Add msoControlButton
Application.CommandBars("dddd").Controls(3).Caption = "粘贴"
Application.CommandBars("dddd").Controls(3).FaceId = 22
Application.CommandBars("dddd").Controls(3).OnAction = "pt"
Application.CommandBars("dddd").showpopup
End If
flag = Not flag
End Sub
Private Sub UserForm_Activate()
flag = False
End Sub
Sub copy2()
Application.SendKeys "^C"
End Sub
Sub cut2()
Application.SendKeys "^X"
End Sub
Sub pt()
Application.SendKeys "^V"
End Sub
相关文章推荐
- OCM_Session7_7_VBOX配置共享存储
- vbs 写文件提示"无效的过程调用或参数"
- VBA取得EXCEL表格中的行数和列数
- 哥德巴赫猜想
- VB.NET视频总结(二)
- Visual Basic.NET不同进制数相互转换
- 【转】浅谈VB.NET中的接口 - 妖居 - 博客园
- VB 动态创建ActiveX控件详解
- access vba动态创建控件
- vb.net向Excel中写入值
- 用VB操作Excel的方法
- VB.NET视频总结(一)
- vb.net与c#相互转换工具
- 在VB和VB.NET程序中判断当前是否运行于开发环境中
- 用VB做通讯录
- vbox导入ovf文件失败
- MVC应用程序播放RealPlayer(rmvb)视频
- vbs 去掉字符串中的空格
- [转] VB之Val()函数的使用
- 关于VB.net禁用右键菜单的实现