On mouse move get element name?

  • Thread starter Internetdomainowner
  • Start date
I

Internetdomainowner

I'm having a difficult time trying to find out how to get this code to
work... I'm hoping someone can help!!! What I am trying to do is the
following...

When the mouse moves on a userform it gets the name of the control is
hovering over... there is one thing though... I've given the userform
the ability to add buttons by it's self using code... my code is
below. Thanks to anyone who can help, if you get me a working solution
I'll tip ya via PayPal.

Private Sub CommandButton10_Click()

Set mycmd = Controls.Add("Forms.CommandButton.1",
UserForm1.Textbox1.Value, True)
mycmd.Caption = UserForm1.Spreadsheet1.ActiveCell.Value
mycmd.Left = 100
mycmd.Top = 20
mycmd.Picture = UserForm1.TextBox2.Value
mycmd.AutoSize = True
mycmd.Visible = True

Set mycmd = Nothing

End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
Dim cCont As Control

'Table2 is the text entered in TextBox1 from above
If UserForm1.cCont.Name = "Table2" Then
UserForm1.TextBox6.Value = cCont.Name
End If


End Sub


I'm then looking to refrence the value brought back in another
macro...


Private Sub TextBox6_Change()

If UserForm1.TextBox6.Value = "Table2" Then
UserForm3.Show
MsgBox "It's been done"
End If

End Sub

Thanks!!!
 
I

Internetdomainowner

I'm having a difficult time trying to find out how to get this code to
work... I'm hoping someone can help!!! What I am trying to do is the
following...

When the mouse moves on a userform it gets the name of the control is
hovering over... there is one thing though... I've given the userform
the ability to add buttons by it's self using code... my code is
below. Thanks to anyone who can help, if you get me a working solution
I'll tip ya via PayPal.

Private Sub CommandButton10_Click()

    Set mycmd = Controls.Add("Forms.CommandButton.1",
UserForm1.Textbox1.Value, True)
    mycmd.Caption = UserForm1.Spreadsheet1.ActiveCell.Value
    mycmd.Left = 100
    mycmd.Top = 20
    mycmd.Picture = UserForm1.TextBox2.Value
    mycmd.AutoSize = True
    mycmd.Visible = True

Set mycmd = Nothing

End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
Dim cCont As Control

'Table2 is the text entered in TextBox1 from above
    If UserForm1.cCont.Name = "Table2" Then
        UserForm1.TextBox6.Value = cCont.Name
    End If

End Sub

I'm then looking to refrence the value brought back in another
macro...

Private Sub TextBox6_Change()

If UserForm1.TextBox6.Value = "Table2" Then
UserForm3.Show
MsgBox "It's been done"
End If

End Sub

Thanks!!!

Nevermind... found out I can do the same thing without having to
dynamically create the command buttons... simply put if I create 150
command buttons and hide them off somewhere and have the system select
the next available button I can achieve the same result... even trying
the following URL didn't lead to much success.

http://www.vbforums.com/showthread.php?t=276191

It's a shame that I wasn't able to use dynamic creation of command
buttons correctly but I get the feeling I'm better off. Thanks to
anyone who was interested enough in looking. Maybe next time =)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top