| Text sent to the printer object is not automatically wrapped across multiple lines. To make this happen you must determine the longest segment that can be printed yourself and send the text in pieces. The following is a quick and dirty routine to show the basic technique: Sub WrapText (strIn As String) Dim lngMax As Long Dim strTemp As String Dim strLine As String Dim x As Integer lngMax = Printer.ScaleWidth strLine = RTrim$(strIn) Do While Len(strLine) x = InStr(strLine, " ") ' find a space If x = 0 Then x = Len(strLine) If Printer.TextWidth(strTemp & Left$(strLine, x)) < lngMax Then strTemp = strTemp & Left$(strLine, x) strLine = Mid$(strLine, x + 1) Else Printer.Print strTemp ' next word is too long to fit strTemp = Left$(strLine, x) strLine = Mid$(strLine, x + 1) End If Loop If Len(strTemp) Then Printer.Print strTemp End Sub |
Wrapping Text |
Express News India | Freelance ecommerce web development India