-
Dec 29th, 2012, 10:11 PM
#1
Thread Starter
New Member
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
------------
-
Dec 29th, 2012, 11:55 PM
#2
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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Dec 30th, 2012, 12:00 AM
#3
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)
-
Dec 30th, 2012, 02:22 AM
#4
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
-
Dec 30th, 2012, 04:30 AM
#5
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
-
Dec 30th, 2012, 04:46 AM
#6
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.
-
Dec 30th, 2012, 06:43 AM
#7
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
-
Dec 30th, 2012, 07:49 AM
#8
Thread Starter
New Member
Re: text to display under Mouse Arrow on CommanBuuton1 while the mouse is hovering.
Originally Posted by westconn1
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.
-
Dec 30th, 2012, 02:15 PM
#9
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
-
Dec 30th, 2012, 03:23 PM
#10
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
-
Dec 30th, 2012, 03:24 PM
#11
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
-
Dec 30th, 2012, 03:29 PM
#12
Thread Starter
New Member
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.
-
Dec 30th, 2012, 03:54 PM
#13
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
-
Dec 31st, 2012, 04:30 AM
#14
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|