Consulting

Results 1 to 9 of 9

Thread: Multi-line Control Tip Text

  1. #1
    VBAX Mentor
    Joined
    Aug 2020
    Location
    Hampshire
    Posts
    395
    Location

    Multi-line Control Tip Text

    I reckon by a long trawl across G***le that there isn't a way to do this. But I'd thought that I would ask anyhow.

    I've tried the following without success.
    TextBox4.ControlTipText = "hello" & vbCrLf & "there"
    TextBox4.ControlTipText = "hello" & vbCr & "there"
    TextBox4.ControlTipText = "hello" & Chr(10) & "there"
    TextBox4.ControlTipText = "hello" & Chr(11) & "there"
    TextBox4.ControlTipText = "hello" & Chr(13) & "there"

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    No way to make a control tip multi-line

    A workaround might be showing and hiding a label.

    This could use some polish

    Capture.JPG


    Option Explicit
    
    
    Private Sub UserForm_Initialize()
        With Me
            .Label1.Top = .TextBox1.Top + 5
            .Label1.Left = .TextBox1.Left + 5
            .Label1.Width = .TextBox1.Width - 5
            .Label1.Caption = "This is" & vbCrLf & "a test" & vbCrLf & "of a multi-line 'tooltip'"
            .Label1.AutoSize = True
        End With
    End Sub
    
    
    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
    
    
    Private Sub CommandButton1_Click()
        UserForm1.Hide
        Unload UserForm1
    End Sub
    
    
    Private Sub TextBox1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        Me.Label1.Visible = True
    End Sub
    
    
    Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
        Me.Label1.Visible = False
    End Sub
    
    
    Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
        Me.Label1.Visible = False
    End Sub
    
    
    Private Sub Label1_Click()
        Me.Label1.Visible = False
    End Sub
    
    
    Private Sub Label1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        Me.Label1.Visible = False
    End Sub
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    Or simpler still, put the instructions on the userform, and/or use a button to display a help text

    2021-03-19_09-55-51.jpg

    2021-03-19_09-57-46.jpg
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  4. #4
    VBAX Mentor
    Joined
    Aug 2020
    Location
    Hampshire
    Posts
    395
    Location
    Many thanks to you both.

    Paul, out of interest I'll look at your suggestion.

    However, Graham has I think come up with the most obvious (hence why I missed it) solution.

    I really like the button design and am hoping to have something similar on my userform. A bit of testing to come!

    Thanks again!

  5. #5
    VBAX Mentor
    Joined
    Aug 2020
    Location
    Hampshire
    Posts
    395
    Location
    Looking to have four different buttons to display four different pieces of text.

    I was thinking something like this might work?

    Private Sub CommandButton1_Click()
        If CommandButton1.Value = True Then
            Label20.Visible = False
            Label20.Text = "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
        Else
            Label20.Visible = True
        End If
    End Sub
    Are showing / hiding labels possible? If they are, what would the default values be on the UserForm?

    Is the above code the best way of showing the separate bits of text? I have each of the buttons by their default names at the moment from 1 to 4. I'd also like the user to be able to select pieces of the text when they are revealed too.

    Steve

  6. #6
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,334
    Location
    Well, you can select the caption of a label control. You could use a textbox control default visible = false:

    Private Sub CommandButton1_Click()
    If TextBox1.Visible Then
    TextBox1.Visible = False
    Else
    TextBox1.Visible = True
    TextBox1.Text = "Whatever"
    End If
    End Sub
    Greg

    Visit my website: http://gregmaxey.com

  7. #7
    VBAX Mentor
    Joined
    Aug 2020
    Location
    Hampshire
    Posts
    395
    Location
    Thanks Greg, this works just fine!

    Is there a way of making the first word bold within the UserForm TextBox.

    I thought that this might do the trick?

    Private Sub CommandButton1_Click()
        Dim rngDoc As Range
        Set rngDoc = ActiveDocument.Range.Words(1)
        rngDoc.Bold = True
        If TextBox10.Visible Then
            TextBox10.Visible = False
        Else
            TextBox10.Visible = True
            TextBox10.Text = "Test - Some other descriptive text to explain further"
        End If
    End Sub
    Of course it might be that this is just not possible?

  8. #8
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,334
    Location
    It is just not possible.
    Greg

    Visit my website: http://gregmaxey.com

  9. #9
    VBAX Mentor
    Joined
    Aug 2020
    Location
    Hampshire
    Posts
    395
    Location
    Thanks, Greg! I thought that was likely to be the answer.

    Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •