How to create tooltip in Command Button!!

ahmed_one

New Member
Joined
Jun 27, 2005
Messages
30
Hi,

I've create a button in VBA/Excel, what i need is to create custom tooltip which display brief description about the button when mouse is hover on it.

Please reply soon.

Thanx

Ahmed
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hello Ahmed, welcome to the board!!

You can use something like this ..


<font face=Courier New><SPAN style="color:#00007F">Option</SPAN> <SPAN style="color:#00007F">Explicit</SPAN>

<SPAN style="color:#00007F">Sub</SPAN> Create_Tooltip()
    <SPAN style="color:#00007F">Dim</SPAN> CBB <SPAN style="color:#00007F">As</SPAN> CommandBarButton
    <SPAN style="color:#00007F">Set</SPAN> CBB = Application.CommandBars("Custom 1").Controls("Custom Button")
    CBB.TooltipText = "VOILA!"
    <SPAN style="color:#00007F">Set</SPAN> CBB = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>

<SPAN style="color:#00007F">Sub</SPAN> Delete_Tooltop()
    <SPAN style="color:#00007F">Dim</SPAN> CBB <SPAN style="color:#00007F">As</SPAN> CommandBarButton
    <SPAN style="color:#00007F">Set</SPAN> CBB = Application.CommandBars("Custom 1").Controls("Custom Button")
    CBB.TooltipText = ""
    <SPAN style="color:#00007F">Set</SPAN> CBB = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>


The first routine puts a tooltip text on the specified button, the second routine takes it off. You must define the command bar name and the button/control name.
 
Upvote 0
<SPAN style="color:#00007F">Sub</SPAN> Create_Tooltip()
<SPAN style="color:#00007F">Dim</SPAN> CBB <SPAN style="color:#00007F">As</SPAN> CommandBarButton
<SPAN style="color:#00007F">Set</SPAN> CBB = Application.CommandBars("Custom 1").Controls("Custom Button")
CBB.TooltipText = "VOILA!"
<SPAN style="color:#00007F">Set</SPAN> CBB = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>

<SPAN style="color:#00007F">Sub</SPAN> Delete_Tooltop()
<SPAN style="color:#00007F">Dim</SPAN> CBB <SPAN style="color:#00007F">As</SPAN> CommandBarButton
<SPAN style="color:#00007F">Set</SPAN> CBB = Application.CommandBars("Custom 1").Controls("Custom Button")
CBB.TooltipText = ""
<SPAN style="color:#00007F">Set</SPAN> CBB = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
i saw these codes, how and where to write these codes in excel vba, I mean how you apply to activex button? i was also looking for tooltip method, but i dont know how to apply these codes
 
Upvote 0
He forgot to wrap it. Just remove all the HTML code. I did not alter the code, nor test it.

VBA Code:
Sub Create_Tooltip()
Dim CBB As CommandBarButton
Set CBB = Application.CommandBars("Custom 1").Controls("Custom Button")
CBB.TooltipText = "VOILA!"
Set CBB = Nothing
End Sub

Sub Delete_Tooltop()
Dim CBB As CommandBarButton
Set CBB = Application.CommandBars("Custom 1").Controls("Custom Button")
CBB.TooltipText = ""
Set CBB = Nothing
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,550
Messages
6,114,265
Members
448,558
Latest member
aivin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top