• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Is it possible to create code for Mouse and Keyboard Movements

sgmpatnaik

Active Member
Hello

Good Morning

I have small doubt that is is it possible to create a code for Mouse and Keyboard Movements, i have searched in google but i fail

so i decided to get the solution from our Gurus / Ninjas

Thanking you

With Regards

Patnaik
 
Hi Patnaik

Yes this is possible the action is called MouseMove. I have a file which shows a picture when the mouse moves over the command button. The code is as follows.

Code:
Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim sh As Worksheet
Set sh = Sheet1
      If sh.Pictures("Smallman").Visible = False Then 'Smallman is the name of the pic
      sh.Pictures("Smallman").Visible = True
      End If
    sh.Shapes("Label1").Visible = True 'This line is the most important (No Delete)
End Sub

Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim sh As Worksheet
Set sh = Sheet1
    If sh.Pictures("Smallman").Visible = True Then 'Smallman is the name of the pic
      sh.Pictures("Smallman").Visible = False
    End If
    sh.Shapes("Label1").Visible = False 'This line is the most important (No Delete)
End Sub

'If you want the Command Button to perform an Action as well then the following will help.

Private Sub CommandButton1_Click()
    MsgBox "Your Macro Here"
End Sub

Where the name of the Picture is Smallman. There is a Label and this next point is very important. The label is clear and it goes completely around the picture.

The file I am using for a personal project but if you share your email address I can send you the file.

Take care

Smallman
 
Back
Top