Width of text to be printed

  • Thread starter Thread starter Jerry Kogan
  • Start date Start date
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?
 
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
 
Back
Top