VERSION 1.0 CLASS BEGIN MultiUse = -1 'True Persistable = 0 'NotPersistable DataBindingBehavior = 0 'vbNone DataSourceBehavior = 0 'vbNone MTSTransactionMode = 0 'NotAnMTSObject END Attribute VB_Name = "ReportAids" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Option Explicit Private lColumns As Integer 'number of character columns in report Private lMaxPointSize As Single Private lMinPointSize As Single Private lOrientation As Integer '=vbPRORPortrait or vbPRORLandscape Private lPageHeight As Single Private lPageWidth As Single Private lPointSize As Single 'point size to use at printer Private lRows As Integer 'number of rows in a report page Public Property Get Columns() As Integer 'Gets/Sets number of columns in page width Columns = lColumns End Property Public Property Get MaxPointSize() As Single 'Gets/Sets maximum point size to use; default=12 MaxPointSize = lMaxPointSize End Property Public Property Let MaxPointSize(ByVal NewMaxPointSize As Single) 'Gets/Sets maximum point size to use; default=12 lMaxPointSize = NewMaxPointSize End Property Public Property Get MinPointSize() As Single 'Gets/Sets minimum point size for portrait orientation; default=8 MinPointSize = lMinPointSize End Property Public Property Let MinPointSize(ByVal NewMinPointSize As Single) 'Gets/Sets minimum point size for portrait orientation; default=8 lMinPointSize = NewMinPointSize End Property Public Property Get Orientation() As Integer 'Gets/Sets number of columns in page width Orientation = lOrientation End Property Public Property Get PageHeight() As Single 'Gets/Sets page height in inches; default=11 PageHeight = lPageHeight End Property Public Property Let PageHeight(ByVal NewPageHeight As Single) 'Gets/Sets page height in inches; default=11 lPageHeight = NewPageHeight End Property Public Property Get PageWidth() As Single 'Gets/Sets page width in inches; default=8.5 PageWidth = lPageWidth End Property Public Property Let PageWidth(ByVal NewPageWidth As Single) 'Gets/Sets page width in inches; default=8.5 lPageWidth = NewPageWidth End Property Public Property Get PointSize() As Single 'Gets/Sets point size to be used PointSize = lPointSize End Property Public Property Get Rows() As Integer 'Gets/Sets point size to be used Rows = lRows End Property Private Function Pad(s As String, l As Long) 'postfix string with blanks to desired length Dim ans As String If Len(s) > l Then Pad = Left$(s, l) Exit Function End If ans = s While Len(ans) < l ans = ans & " " Wend Pad = ans End Function Public Function SetupReport(RptColumns As Integer) As Integer 'Sets Printer and establishes Orientation and Sizing for requested RptColumns ' Tested for 70-170 RptColumns using HP LaserJet III printer. (usable throughout range) ' Tested for 70-170 RptColumns using HP Color LaserJet 5 printer. (usable throughout range) lPointSize = (120 * (lPageWidth - 0.75)) / RptColumns 'get type size for Portrait orientation If lPointSize >= MinPointSize Then 'Portrait sizing is acceptable for most eyes If lPointSize > MaxPointSize Then lPointSize = MaxPointSize 'ANYBODY can read this size lRows = Int((66 * (lPageHeight - 0.5)) / lPointSize) 'get number of rows that will fit If lPointSize <= 7.75 Then lRows = Rows - 1 'correct for anomaly lOrientation = vbPRORPortrait 'set orientation Else 'Landscape required due to smallness of print lPointSize = (120 * (lPageHeight - 0.75)) / RptColumns 'get type size for Landscape orientation lRows = Int((66 * (lPageWidth - 0.5)) \ lPointSize) 'get number of rows that will fit If lPointSize < 9.5 Then lRows = Rows - 2 'correct for anomaly lOrientation = vbPRORLandscape 'set orientation End If Printer.Font = "Courier New" 'set the Printer Printer.FontSize = lPointSize Printer.Orientation = Orientation SetupReport = Rows lColumns = RptColumns End Function Public Function TitleLine(LeftText, CenterText, RightText) 'Returns Text line of Columns characters constructed from Left, Center, and Right segments Dim ans As String ans = Pad(CStr(LeftText), (Columns - Len(CenterText)) \ 2) + CenterText ans = Pad(ans, Columns - Len(RightText)) + RightText TitleLine = ans End Function Private Sub Class_Initialize() lPageWidth = 8.5 lPageHeight = 11 lMaxPointSize = 12 lMinPointSize = 8 End Sub