Width of text to be printed

J

Jerry Kogan

If you know the font, and the text that will go into an
actual text box, is there any way you can find out the
actual width of the text that will be printed. The only
thing I've seen that might come close is to set up the
control as size to fit, and then get the size of the
control during the Report's format event. Is there some
routine where you can specify a font size, type, and text,
and find out how much space would be require to print that
text?
 
M

Marshall Barton

Jerry said:
If you know the font, and the text that will go into an
actual text box, is there any way you can find out the
actual width of the text that will be printed. The only
thing I've seen that might come close is to set up the
control as size to fit, and then get the size of the
control during the Report's format event. Is there some
routine where you can specify a font size, type, and text,
and find out how much space would be require to print that
text?


If the text is all on one line, you can use the report's
TextWidth property. Set the report's properties and then
check the length:

Me.FontName = Me.textbox.FontName
Me.FontSize = Me.textbox.FontSize
Me.FontBold = (Me.textbox.FontBold = 1)
lngstringwidth = TextWidth(Me.textbox)

If the string can be more than one line, then you'd best use
Stephen Lebans' TextHeightWidth function at www.lebans.com
 

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