Varying font size dynamically

G

Guy Scharf

I have a need to print a text field in a fixed space. If the text in
the field is long, I need to reduce the font size so that it will all
fit.

How might I accomplish that?

Thanks.

Guy
 
M

Marshall Barton

Guy said:
I have a need to print a text field in a fixed space. If the text in
the field is long, I need to reduce the font size so that it will all
fit.


Very tricky problem. Fortunately Stephen Lebans has worked
out the really complex part at
http://www.lebans.com/textwidth-height.htm

Once you download and import the module, you can use code
something like:

For FS = 12 To 4 Step -1
If fTextHeight(Me.thetextbox) < Me.thetextbox.Height _
And fTextWidth(Me.thetextbox) < Me.thetextbox.Width _
Then Exit For
Next FS
Me.thetextbox.FontSize = FS
 
G

Guy Scharf

Marsh,

Thank you. I've got that working as desired, with a few minor changes.

Guy
 

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