PDA

View Full Version : Solved: Control Tip Text



CarlosB
11-26-2008, 02:15 PM
I am creating different user forms in Excel 2003 through VB. Each form has several labels. I need to provide an extensive tip text description for each label using the controltiptext option. I am able to do so, either through vb code or in the label properties; however, I have not been able to insert line breaks to present the information in multiple lines. Does any one knows how to do it?

I have tried the code below but is not working.

Label1.ControlTipText = "Information1" _
& vbCrLf & "Information2"


Thanks in advance.

georgiboy
11-26-2008, 02:37 PM
Have you tried vbnewline

MsgBox "Hello line1" & vbNewLine & "Hello line2" & vbNewLine & vbNewLine & "Hello line4"

hope this helps

GTO
11-26-2008, 02:59 PM
Hi Carlos,

As a label's job is to provide a description, why do you need to describe the description (so-to-speak)?

To answer your question though, I tried vbNewLine, vbCr, etc, before realizing or recalling that I'd been down this road before... I have never found a way of creating any type of carriage return for a control tip. I would tend to believe that it's not possible, as if you assign a long text string to it, you'll note that Excel doesn't wrap the text on it's own (such as it does for a msgbox).

Mark

CarlosB
11-26-2008, 04:24 PM
.

CarlosB
11-26-2008, 04:37 PM
Georgi:

I could try your code, but I am not using msgbox, instead I am showing this as a tip when the user places the cursor over any label. Copy this link in your browser so you can see what I am talking about.

img444.imageshack.us/img444/6849/controltiptexen2.jpg

CarlosB
11-26-2008, 04:42 PM
I agree with you GTO but my boss wants to include such long description. But maybe I should just stop trying and let him know that is not possible.

Carl A
11-26-2008, 06:37 PM
Check this thread for a work around:

http://www.vbaexpress.com/forum/showthread.php?t=22642

CarlosB
11-26-2008, 11:24 PM
Thanks you Carl, I could not implement your code, but pretty much you gave the idea of how to do it. What I did was using three different sub routines.

1. Prevents the Label1 (used as Control Tip Text) to be seen when userform becomes active.
Private Sub UserForm_Activate()
Me.Label1.Visible = False
End Sub
2. Makes Label1 visible when mousemove event is true. And sets Color to yellow
Private Sub Label2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Me.Label1.Visible = True
Me.Label1.BackColor = RGB(255, 255, 153)
End Sub
3.Label1 becomes invisible when mousemove is out of Label2 range (Lable for which the control tip text is needed)

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

See Result
<img361.imageshack.us/img361/1221/controltiptextbw5.jpg>

I also included an example file.

Thanks again Carl