PDA

View Full Version : Changing Tooltip size and color



simora
12-26-2010, 03:24 PM
How can I change the size and color of the tooltips on a 2003 Excel Userform?

My Tooltips are very small, and was created in the Userform properties.

macropod
12-26-2010, 09:04 PM
Hi Simora,

Tooltip attributes are controlled at the Windows system level - not at the application or file level. So, if you change them, all applications are affected.

If you really want to go ahead with this, right-click on the Desktop and select Properties > Appearances > Advanced > Appearance > Item > ToolTip. From there you can play with the font attributes.

simora
12-26-2010, 10:11 PM
macropod:

Thanks.
I was hoping that one could use something like altering the shape at the UserForm level. Maybe a modification of something like this
http://en.allexperts.com/q/Excel-1059/tooltip-CommandButton.htm

mikerickson
12-27-2010, 12:25 AM
You could add Label1 to the userform and format it the way that you like.

Then put this code in the userform's code module.
Any control whose MouseMove event calls CommonToolTip will have it's ControlTipText displayed in Label1 rather than the standard tool tip box.

A control's ControlTipText can be changed at run time or at design time. (e.g. CommandButton2)
Private Sub ListBox1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
Call CommonToolTip(ListBox1, x)
End Sub

Private Sub TextBox1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
Call CommonToolTip(TextBox1, x)
End Sub

Private Sub TextBox2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
Call CommonToolTip(TextBox2, x)
End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
With Label1
.Caption = "null"
.Visible = False
End With
End Sub

Sub CommonToolTip(aControl As Object, Optional x As Single)
With aControl
If .ControlTipText <> vbNullString Then
.Tag = .ControlTipText
.ControlTipText = vbNullString
End If
Label1.Visible = (.Tag <> vbNullString)
If Label1.Caption <> .Tag Then
Rem if newly shown
Label1.AutoSize = False
Label1.Width = 150
Label1.Height = 150
Label1.Caption = .Tag
Label1.AutoSize = True
Label1.AutoSize = False

Label1.Top = .Top + .Height
Label1.Left = .Left + (.Width / 2) + (Label1.Width * (x > (.Width / 2)))

Do Until Label1.Left + Label1.Width < UserForm1.Width
Label1.Left = Label1.Left - 5
Loop
If Label1.Left < 0 Then Label1.Left = 5

If (.Parent.Height) < (Label1.Top + Label1.Height) + 22 Then
Label1.Top = .Top - Label1.Height
End If

End If
End With
End Sub

Private Sub CommandButton2_Click()
TextBox2.ControlTipText = "TB 2"
End Sub

Note that ComboBox1 does not have a MouseMove event and shows the standard tool tip.

Sean.DiSanti
12-27-2010, 02:25 PM
you can also use the office assistant to say whatever you'd put in the tooltip

Bob Phillips
12-27-2010, 05:30 PM
you can also use the office assistant to say whatever you'd put in the tooltip

You aren't serious are you? No self-respecting Office user uses the office assistant.

mikerickson
12-27-2010, 06:35 PM
xld,
You don't miss Clippy and Max ?!?

Anyway, the Office Assistant has been depreciated since 2003(?)

macropod
12-27-2010, 07:48 PM
Anyway, the Office Assistant has been depreciated since 2003(?)I think that's deprecated ...

mikerickson
12-27-2010, 08:53 PM
If you want the user to hear the tool tip, you could use code like this:
Private Sub TextBox1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
Const Border As Long = 5
Static Spoken As Boolean
Static timeHack As Date

If x < Border Or ((TextBox1.Width - x) < Border) _
Or y < Border Or ((TextBox1.Height - y) < Border) Then
Spoken = False
timeHack = 0
Else
If timeHack = 0 Then timeHack = Now

If (Not Spoken) And (TextBox1.ControlTipText <> vbNullString) Then
If TimeSerial(0, 0, 1) < (Now() - timeHack) Then

#If Mac Then
MacScript "say "" " & TextBox1.ControlTipText & " "" "
#Else
Rem code for Windows
#End If

Spoken = True
End If
End If
End If
End Sub

Bob Phillips
12-28-2010, 03:50 AM
I think that's deprecated ...

Yeah, it was depreciated (not appreciated) long before :)

Sean.DiSanti
12-30-2010, 04:04 PM
lol, your business must be a lot better off than mine if the people using your tools are self respecting office users. We still use 2003 over here, and manipulating the office assistant can be fun sometimes. Once i had a request to make clippy "talk to" a user a couple times a day. Nothing mean or anything, just the normal "how's your day going?", "wanna talk about it" kind of stuff. it was pretty funny, after a while she asked about it, and we just told her that 2003 was just more "user friendly"

Bob Phillips
12-30-2010, 04:30 PM
I bet you use those horrible cut-down menus as well.

Sean.DiSanti
12-30-2010, 05:10 PM
i actually don't know what you're talking about, and i don't use the office assistant, but the hiring process for the agents on the floor here is basically to check them for a pulse, so it's a fair assumption they work with clippy on their screen all day

Bob Phillips
12-30-2010, 05:37 PM
In Excel 2003, the menus (File, Edit, Format, etc.) when clicked on would typically only show the last 4 menu items that the user had used, there would be a chevrons item at the bottom to open up the rest. You had to go into Customize to get it to show all items at all times. Another MS genius idea.

Sean.DiSanti
12-30-2010, 06:09 PM
ah, yeah, i mostly use hotkeys for everything so i don't even notice the menus

simora
01-01-2011, 04:07 AM
Happy New Year!

Great ideas all. Thanks

I took off for a moment. I'll look into the code provided.
I actually use 2003 and if the Office Assistant can be made to provide real assistance, I'll use it if it helps the users.

simora
01-01-2011, 04:37 AM
you can also use the office assistant to say whatever you'd put in the tooltip

Sean.DiSanti:
Do you happen to have the process to use the office assistant to say whatever you'd put in the tooltip. That'll be a great learning tool to have.

Thanks

simora
01-01-2011, 04:39 AM
You could add Label1 to the userform and format it the way that you like.

Then put this code in the userform's code module.
Any control whose MouseMove event calls CommonToolTip will have it's ControlTipText displayed in Label1 rather than the standard tool tip box.

.

mikerickson:
Your original code worked.
Couldn't quite get the spoken one to work yet.

Thanks again.

Sean.DiSanti
01-03-2011, 04:32 PM
Hey, i've been off for a couple of days, sorry for the slow response... here's a paste from help under the heading "Creating and modifying balloons" (this is just a brief example, a lot more is covered in that help entry



The following example creates a balloon that helps the user select a printer. The example provides a check box option for users who want to skip the information in the balloon.


Set bln = Assistant.NewBalloon
With bln
.Heading = "Instructions for Choosing a Printer."
.Text = "Click OK when you've chosen a printer."
lblTxt = "From the File menu, choose Print."
.Labels(1).Text = lblTxt
.Labels(2).Text = "Click Setup."
.Labels(3).Text = "Select the name of the printer."
.CheckBoxes(1).Text = "Skip this information."
.BalloonType = msoBalloonTypeNumbers
.Mode = msoModeModal
.Button = msoButtonSetOK
.Show

End With

mikerickson
01-03-2011, 08:39 PM
...
Couldn't quite get the spoken one to work yet.

The code I posted will work on a Mac.
The conditional formating has a comment asking for Windows code that will say the string TextBox1.ControlTipText .

simora
01-04-2011, 01:41 AM
mikerickson:
Sean.DiSanti:

Got it:

Thanks

Sean.DiSanti
01-10-2011, 11:28 AM
np, glad to help