?
Solved

How to create a line break on ControlTipText in VBA

Posted on 2009-02-08
16
Medium Priority
?
3,868 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.

0
Comment
Question by:FaheemAhmadGul
  • 5
  • 4
  • 3
  • +2
16 Comments
 
LVL 25

Expert Comment

by:reb73
ID: 23583989
Just add the following where you need a linebreak -

char(13) + char(10)

or

vbcrlf


0
 
LVL 1

Author Comment

by:FaheemAhmadGul
ID: 23584127
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.
0
 
LVL 25

Expert Comment

by:reb73
ID: 23584152
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"

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:FaheemAhmadGul
ID: 23584430
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.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 600 total points
ID: 23584471
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(),
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 23584495
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
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 23584513
Which application are you using? I think that it is possible in Access, which uses Access Forms rather than Forms 2.
0
 
LVL 1

Author Comment

by:FaheemAhmadGul
ID: 23584573
Thanks for your responses to my question.
I am using Word.
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 23584585
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
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 23584663
Yes, Faheem. I did expect that you were using Word. In that case my first comment stands.
0
 
LVL 1

Author Comment

by:FaheemAhmadGul
ID: 23584787
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 ?
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 23586319
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.
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 23588527
Looks like Graham had it tied down in his first post.

Chris
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 23592675
You can use the CreateWindowEx API to achieve this:

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

Author Closing Comment

by:FaheemAhmadGul
ID: 31544692
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
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month15 days, 8 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question