Public Function CheckForNewPage(sSpaceNeeded As Single, Optional LeftSet As Single, Optional TopSet As Single, Optional PageNo As Long) As Boolean
On Error Goto ErrorHandler Dim sFontSize As Single With Printer If sSpaceNeeded > ((.Height / 1440) - 0.25) Then sFontSize = .FontSize .FontSize = 6 PrintPageNo PageNo .NewPage .CurrentX = 0.5 .CurrentY = 0.5 Printer.Print "(Cont.)" If LeftSet = 0 Then .CurrentX = 1 Else .CurrentX = LeftSet If TopSet = 0 Then .CurrentY = 0.7 Else .CurrentY = TopSet .FontSize = sFontSize CheckForNewPage = True End If End With Exit Function ErrorHandler: MsgBox Error & vbCr & " NewPage" End Function Inputs:sSpaceNeeded = height of the text your going to print PLUS the current Y coordinate. Optional LeftSet and TopSet For top and left margines, If applicable PageNo, a Long variable. Returns: This function is boolean -- returns TRUE if a new page was generated,this way you not only make your new page but you know you're consequently back at the top again. Assumes:Used with the Printer Object. Can be used in conjunction with PrintPage No. |