We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

How to create a line break on ControlTipText in VBA

FaheemAhmadGul
on
Medium Priority
6,453 Views
Last Modified: 2012-05-06
I have some buttons on my VBA project form with ControlTipText which becomes visible when the user hovers over the button during run time. For some of these buttons ControlTipText is rather long and does not look very nice when it shows up as a very long single line when the user hovers on the relevant button. I just wish to know if there is a way you can force a manual line break on the ControlTipText so that it appears as a small paragraph rather than a single long line at run time.
Many thanks for your help.

Comment
Watch Question

Commented:
Just add the following where you need a linebreak -

char(13) + char(10)

or

vbcrlf


Author

Commented:
Thank you for your prompt response to my question.
I have tried your suggestion but it did not work. Instead the code words you have suggested appear as part of the ControlTipText where I enter these.
Please note that I am using Visual Basic For Applications.

Commented:
What you have to do is as follows -

If your controltiptext is say "This is a very very very very very very long sentence",

your VBA code should like this to get a line break after the third very -

<Control>.ControlTipText = "This is a very very very very" & vbcrlf & _
                                            "very very very long sentence"

or

<Control>.ControlTipText = "This is a very very very very" & char(13) & char(10) & _
                                            "very very very long sentence"

Author

Commented:
Unfortunately, the control tip text sill all appears as one line.
So
btnMyControl.ControlTipText = "This is a very very very" & vbcrlf & _
                                            "very very very long sentence"
Appears as
This is a very very very very very very long sentence

As it is taking more time than I thought, I have increased the points to 150.
Retired
CERTIFIED EXPERT
Top Expert 2012
Commented:
The text is confined to a single line by design.  The carriage return and line feed characters are simply displayed as open squares (invalid).

Incidentally the function is Chr() or Chr$(), rather than char(),

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
CERTIFIED EXPERT
Top Expert 2011

Commented:
Hello FaheemAhmadGul,

Sorry i'm not helping initially, but I came across something a while back which I used at work for the purpose, it involved something like pasting the text into another application and then pasting back into the field control.  I will see if I kept a note of it tomorrow ... if you're still looking.

Regards,
Chris
GrahamSkanRetired
CERTIFIED EXPERT
Top Expert 2012

Commented:
Which application are you using? I think that it is possible in Access, which uses Access Forms rather than Forms 2.

Author

Commented:
Thanks for your responses to my question.
I am using Word.
CERTIFIED EXPERT
Top Expert 2011

Commented:
Then I may not be of any help even if I find it ... I used it in an access application, still and all i'll see what I can see.

Chris
GrahamSkanRetired
CERTIFIED EXPERT
Top Expert 2012

Commented:
Yes, Faheem. I did expect that you were using Word. In that case my first comment stands.

Author

Commented:
I did try using Chr(13) & Chr(10) as Char(13) & Char(10) was giving error.
Chr(13) & Chr(10) did not give an error but did not create a line break either.
Does this mean it is not possible to create line break in ControlTipText in Word ?
GrahamSkanRetired
CERTIFIED EXPERT
Top Expert 2012

Commented:
That's what I think. In Forms 2.0, the tooltip is not designed to interpret the characters as carriage return and line feed, and has no facility to double the height of the bubble and to restart the text on another line.
CERTIFIED EXPERT
Top Expert 2011

Commented:
Looks like Graham had it tied down in his first post.

Chris

Commented:
You can use the CreateWindowEx API to achieve this:

Create Multi Line ToolTip Windows
http://www.thescarms.com/vbasic/tooltip.aspx

Author

Commented:
I am accepting Graham's conclusion as the right  answer as it seems it is not possible to achieve what I was trying to achieve using VBA in Word.
I, however, thank all others who have very kindly contributed to the discussion and tried to help me. Regards. Faheem
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.