用VBA如何在word中响应鼠标左键事件
1个回答
展开全部
这个太简单,但是需要用VBa窗体来完成
你用VBa建立一个窗体,然后在窗体中添加一个按钮,然后代码复制好,在窗体里点完后,按下按钮就知道右,左键各点击了多少次了
点开窗体代码写入:
Dim i As Integer
Dim j As Integer
Private Sub CommandButton1_Click()
MsgBox "共点击了" & i & "次右键"
MsgBox "共点击了" & j & "次左键"
i = 0
j = 0
End Sub
Private Sub UserForm_Click()
i = i + 1
End Sub
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 2 Then
j = j + 1
End If
End Sub
你用VBa建立一个窗体,然后在窗体中添加一个按钮,然后代码复制好,在窗体里点完后,按下按钮就知道右,左键各点击了多少次了
点开窗体代码写入:
Dim i As Integer
Dim j As Integer
Private Sub CommandButton1_Click()
MsgBox "共点击了" & i & "次右键"
MsgBox "共点击了" & j & "次左键"
i = 0
j = 0
End Sub
Private Sub UserForm_Click()
i = i + 1
End Sub
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 2 Then
j = j + 1
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |