TextHeight, TextWidth Methods Example
The following example uses the TextHeight and TextWidth methods to determine the amount of vertical and horizontal space required to print a text string in the report's current font.
To try this example in Microsoft Access, create a new report. Set the OnPrint property of the Detail section to [Event Procedure]. Enter the following code in the report's module, then switch to Print Preview.
Private Sub Detail_Print(Cancel As Integer, _
PrintCount As Integer)
' Set unit of measure to twips (default scale).
Me.Scalemode = 1
' Print name and font size of report font.
Debug.Print "Report Font: "; Me.FontName
Debug.Print "Report Font Size: "; Me.FontSize
' Print height and width required for text string.
Debug.Print "Text Height (Twips): "; _
Me.TextHeight("Product Report")
Debug.Print "Text Width (Twips): "; _
Me.TextWidth("Product Report")
End Sub