To show the whole text in a tooltip text

P

Pierre Archambault

Hi,

I have UserForm which contains a textBox which cannot always display all of
its content because the width of the textBox is limited by my program. I
would like to give the user the possibility to see all of its content by
showing a tooltip text like the one we have when for instance, the left
window of Windows Explorer isn't wide enough to show its whole content. When
the mouse passes over the truncated text, we can see it in that tooltip
text. Is there a way we can do the same in Excel ?

I dont want to always show that tooltip text: it would not be usefull when
the text is short enough to be visible in the textBox. I don't want either
the textBox to be multiline neither have a scrollbar; its height must be
fixed at 1 line.

Thanks.

Pierre
 
R

RB Smissaert

Private Sub TextBox1_Change()

If Len(TextBox1) > 25 Then
TextBox1.ControlTipText = TextBox1
Else
TextBox1.ControlTipText = ""
End If

End Sub

RBS
 
P

Pierre Archambault

Wow !

Who told you that the text that goes in the textBox was 25 characters long ?
 
P

Pierre Archambault

Hi,

No it wasn't

But wait, I found a way to solve the problem...

General section level of UserForm:
Public BoxWidth As Single

Private Sub UserForm_Initialize()
BoxWidth=150 'Initial width of the control

Public DisplayText()

txtBox1 = Trim(MyString)
txtBox1.ControlTipText = ""
txtBox1.AutoSize = True
If txtBox1.Width > BoxWidth Then
txtBox1.ControlTipText = Trim(MyString)
End If
txtBox1.Width = BoxWidth
txtBox1.AutoSize = False

End Sub

Thanks anyway
Pierre
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top