Multiline tooltip on a userform control

ttt123

Board Regular
Joined
May 31, 2006
Messages
120
Office Version
  1. 365
Platform
  1. Windows
Does anyone know how to make a tooltip multiline? Adding vbcrlf to the string assign to the tooltip doesn't seem to work.

-Taylour
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
You cannot directly.

If you do something like this:


Private Sub UserForm_Initialize()

myMsg = "Picture" & vbLf & "Use ""Select Image"" Button," & _
vbLf & "to change picture!"

Me.Image1.ControlTipText = myMsg

MsgBox myMsg
End Sub


When you Show the UserForm a MsgBox opens with the message correctly line-fed but the TipText is not!

ControlTipText is un-Formatted.
 
Upvote 0
Hello,

You could play a bit with the mousemove-event.
This was the result of my game.
Code:
Option Explicit

Dim flag As Boolean

Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub TextBox1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
If flag = True Then Exit Sub
flag = True

Const msg As String = "This is the most important message you've ever read." & vbLf & _
"This is your CustomControlTipText with linefeed." & vbLf & _
"Major drawback is it will only be shown once. Perhaps you can invent a system to enhance this." & vbLf & vbLf & _
"This message will delete itself in 7 seconds:-)" & vbLf & _
"Or you can get rid of it by clicking OK!"
CreateObject("WScript.Shell").Popup msg, 7, "Title"

TextBox1.SetFocus
End Sub
kind regards,
Erik
 
Upvote 0
Hi everyone, thanks for your help. I managed to create a solution to the problem that is quite easy just incase someone wants to use it in the future.

1) Store the tooltip for a control in the tag property of the control (not sure if you can put vbcrlf in manually so I set the tag property on userform_initialize)
2) Add a label that contains a colored background to your form
3) do some code like the code below, resizing the label to make it the same width as the largest input line would make it look even nicer. I would suggest create function that will return a height and width of the control tip label based on the length of the caption and the size of the font

Private Sub UserForm_Initialize()
myToolTipLabel.Visible = False

'add whatever tooltips you want to the tag property of the buttons
TestButton1.Tag = "This is the first line of tooltips for TestButton1" & vbCrLf & "This is the second line"
TestButton2.Tag = "This is the first line of tooltips for TestButton2" & vbCrLf & "This is the second line"
End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
myToolTipLabel.Visible = False
End Sub

Private Sub TestButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
myToolTipLabel.Visible = True
myToolTipLabel.Top = TestButton1.Top + TestButton1.Height + 5
myToolTipLabel.Left = TestButton1.Left
myToolTipLabel.Caption = TestButton1.Tag
End Sub

Private Sub TestButton2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
myToolTipLabel.Visible = True
myToolTipLabel.Top = TestButton2.Top + TestButton2.Height + 5
myToolTipLabel.Left = TestButton2.Left
myToolTipLabel.Caption = TestButton2.Tag
End Sub
 
Upvote 0
thank you for sharing this: it is very nice: mousemove + tag ...

a classmodule can be used to avoid multiple similar coding
 
Upvote 0
Hi Guys, hi Erik,

a classmodule can be used to avoid multiple similar coding

Can you please elaborate more?
How can i add module class in order to avoid code repeating?

Can you please share an example?

Best Wishes,
Jacek
 
Upvote 0

Forum statistics

Threads
1,215,097
Messages
6,123,076
Members
449,094
Latest member
mystic19

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