text to display under Mouse Arrow on CommanBuuton1 while the mouse is hovering.-VBForums
Results 1 to 14 of 14

Thread: text to display under Mouse Arrow on CommanBuuton1 while the mouse is hovering.

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2012
    Posts
    5

    text to display under Mouse Arrow on CommanBuuton1 while the mouse is hovering.

    Hi,
    I need help in enabling a text to appear below the mouse when the mouse is hovering on CommandButton1 in the Excel. I tried using the above code in VB 6.5 Editor in Excel. The code didnt do any thing when the mouse is hovering on the CommanButton1. Here is the code. Would you please look into?

    --------------------
    Private Sub CommandButton1_Click()

    Dim stFolder As String


    stFolder = "C:\Documents and Settings\a\My Documents\Folder"

    If Len(Dir(stFolder, vbDirectory)) <> 0 Then
    Shell "Explorer.exe /n,/e," & stFolder, vbNormalFocus
    Else
    MsgBox "The folder is either removed or renamed!", vbCritical
    End If

    End Sub
    ---------------------
    Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    If X < 1 Or X > CommandButton1.Width - 1 Or Y < 1 Or Y > CommandButton1.Height - 1 Then
    caption = "Hi" ' change to desired effect
    Else
    caption = "Hello"
    End If

    End Sub
    ------------

  2. #2
    Web developer Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    12,471

    Re: text to display under Mouse Arrow on CommanBuuton1 while the mouse is hovering.

    Just to point out Office uses VBA which is not vb6! I have requested the thread moved.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    Please consider giving me some rep points if I help you a lot.
    Links to my code examples can now be found on my website: My websites
    Please rate my post if you find it helpful!
    Technology is a dangerous thing in the hands of an idiot! I am that idiot.

  3. #3
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    3,132

    Re: text to display under Mouse Arrow on CommanBuuton1 while the mouse is hovering.

    Code:
    Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        Caption = "Hi"  'change to desired effect
    End Sub
    
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Caption = "Hello"
    End Sub
    Code:
    Private Sub CommandButton1_Click()
        Dim stFolder As String
    
        stFolder = "C:\Documents and Settings\a\My Documents\Folder"
    
        If DirExists(stFolder) Then
            Shell "Explorer.exe /n,/e," & stFolder, vbNormalFocus
        Else
            MsgBox "The folder is either removed or renamed!", vbCritical
        End If
    End Sub
    
    'GetAttr is much faster than Dir
    Private Function DirExists(ByRef sPath As String) As Boolean
        On Error Resume Next
        DirExists = (GetAttr(sPath) And vbDirectory) = vbDirectory
    End Function
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0

    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  4. #4
    PowerPoster
    Join Date
    May 2002
    Posts
    24,743

    Re: text to display under Mouse Arrow on CommanBuuton1 while the mouse is hovering.

    I think what you're looking for is the TOOLTIP property... you should be able to just set it at design time...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    19,820

    Re: text to display under Mouse Arrow on CommanBuuton1 while the mouse is hovering.

    in vba it is controltiptext property of commandbutton
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,033

    Re: text to display under Mouse Arrow on CommanBuuton1 while the mouse is hovering.

    VBA hosts provide entirely different widget set frameworks from the one for actual Visual Basic programs. One of the many reasons why VBA questions don't belong intermixed with VB questions.

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    37,038

    Re: text to display under Mouse Arrow on CommanBuuton1 while the mouse is hovering.

    Thread moved to the 'Office Development/VBA' forum... note that while it certainly isn't made clear, the "VB Editor" in Office programs is actually VBA rather than VB, so the 'VB6' forum is not really apt

  8. #8

    Thread Starter
    New Member
    Join Date
    Dec 2012
    Posts
    5

    Re: text to display under Mouse Arrow on CommanBuuton1 while the mouse is hovering.

    Quote Originally Posted by westconn1 View Post
    in vba it is controltiptext property of commandbutton
    what would be the vba code to do such? the code will allow to display a text under the mouse tail when the user hovers mouse on the CommandButton1.

  9. #9
    PowerPoster
    Join Date
    May 2002
    Posts
    24,743

    Re: text to display under Mouse Arrow on CommanBuuton1 while the mouse is hovering.

    It's threads like this that make me want to bash my head in with a hammer... there. is. no. code. It. is. a. property. that. you. set. at. design. time.... clearly you didn't bother to do any searching in the documenation or on Google for it... since you can't be arsed to do that little bit, I don't know why I should bother to continue to help.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  10. #10
    PowerPoster
    Join Date
    Dec 2004
    Posts
    19,820

    Re: text to display under Mouse Arrow on CommanBuuton1 while the mouse is hovering.

    It. is. a. property. that. you. set. at. design. time....
    or run time

    display a text under the mouse tail
    it appears at the mouse pointer,

    what would be the vba code to do such?
    commandbutton1.controltiptext = "This is a test"
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  11. #11
    PowerPoster
    Join Date
    May 2002
    Posts
    24,743

    Re: text to display under Mouse Arrow on CommanBuuton1 while the mouse is hovering.

    Yeah, and I can tell you what the next question is... "where to put the code?"

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  12. #12

    Thread Starter
    New Member
    Join Date
    Dec 2012
    Posts
    5

    Re: text to display under Mouse Arrow on CommanBuuton1 while the mouse is hovering.

    i looked in MS Excel, for CommanBuuton1 ' Property window there is no controltiptext in there. This design work is done in MS Excel 2007, with vba editor (Developer-> Design mode). looks like manual vba code is needed for controltiptext to work.

    techgnome, please ignore this thread; issue here is too elementary for you. i apologize.

  13. #13
    PowerPoster
    Join Date
    May 2002
    Posts
    24,743

    Re: text to display under Mouse Arrow on CommanBuuton1 while the mouse is hovering.

    It's not that the issue is too elementary... it's the apparent lack of effort on your part to do some research...
    I opened google and typed in "how to set tooltips in excel form VBA"

    Here's one of the many results... http://xlvba.fr.yuku.com/topic/89

    https://www.google.com/search?q=how+...in+excel+forms


    THAT is what's chapping my hide...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  14. #14
    PowerPoster
    Join Date
    Dec 2004
    Posts
    19,820

    Re: text to display under Mouse Arrow on CommanBuuton1 while the mouse is hovering.

    This design work is done in MS Excel 2007
    as i am still using excel 2000, and probably will still be using in 2030, i can not tell if there is some difference in msforms controls between versions, though there have been very few other changes

    to do it manually, have a hidden label and show it (and position it) using code from post #1 (instead of changing the form caption)
    the mousemove code is not foolproof and can be defeated with fast jerky mousemovements
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.