JUSTIFICAR TEXTO NA IMPRESSAO ?

PASCOAL 25/04/2010 06:01:23
#340175
Como justificar texto na hora da impressão ?
PASCOAL 25/04/2010 07:24:16
#340176
JÁ CONSEGUI...................................OBRIGADO
PASCOAL 25/04/2010 09:59:08
#340179
Axhei essa função na net funciona perfeitamente mas não consigo fazer que ao encontrar um RETURN ele inicia uma nova linha alguem pode me ajudar?

A Função :

Public Sub PrintJustify(ByVal strText As String, xLeft As Integer, xRight As Integer, yStart As Integer, Optional ySpacing As Integer)
Dim aWords() As String [ô]Array containing all the words in strText
Dim iWords As Integer [ô]The Number of words that will be printed in the current iLine
Dim iWidth As Integer [ô]The available space For a line To print in
Dim iLine As Integer [ô]The current line To be printed
Dim xSpace As Integer [ô]The amount of Space between Each word To be printed
Dim xPrint As Integer [ô]The x position that the Next word will be printed in
Dim yPrint As Integer [ô]The y position that the Next word will be printed in
Dim strWords As String [ô]A string containing the words of the line To be printed
Dim i As Integer [ô]For/Next counter Variable
Dim j As Integer [ô]For/Next counter Variable
[ô]Replace any CRLF with space
strText = Replace(strText, vbCrLf, [Ô] [Ô])
[ô]Replace any [Ô] [Ô] with [Ô] [Ô]
strText = Replace(strText, [Ô] [Ô], [Ô] [Ô])
[ô]Remove any before or after spaces
strText = Trim(strText)
[ô]Initialize Line Counter
iLine = 0
[ô]Set ySpacing Default


If ySpacing = 0 Then
ySpacing = 250
End If
[ô]Calculate Width of Print Column
iWidth = xRight - xLeft
[ô]Keep Processing until all lines have be
[ô] en printed


Do Until strText = [Ô][Ô]
MyQtde_Lin = MyQtde_Lin + 1
MyQtd_Linha_Hist = MyQtd_Linha_Hist + 1
[ô]Increment Line Counter
iLine = iLine + 1
[ô]Calculate yPrint
yPrint = yStart + ((iLine - 1) * ySpacing)
[ô]Break strText into pieces
Erase aWords
aWords = Split(strText, [Ô] [Ô])
[ô]Determine How many words can fit in lin
[ô] e
strWords = [Ô][Ô]


For i = 0 To UBound(aWords)
If i = 0 Then
strWords = aWords(0)
Else
strWords = strWords & [Ô] [Ô] & aWords(i)
End If

If Printer.TextWidth(strWords) > iWidth Then
iWords = i - 1 [ô]last word becomes first word of Next line
Exit For
End If
Next i
[ô]Rewrite StrText if Words are still left
[ô]
strText = [Ô][Ô]


If iWords < UBound(aWords) Then


For i = iWords + 1 To UBound(aWords)


If i = iWords + 1 Then
strText = aWords(i)
Else
strText = strText & [Ô] [Ô] & aWords(i)
End If
Next i
Else [ô]Print Last Line With No Justification
Printer.CurrentX = xLeft
Printer.CurrentY = yPrint
Printer.Print strWords
Exit Sub
End If
[ô]Now we can Print Justified Line
[ô]Get Width of all Words to be Printed (N
[ô] o Spaces)
strWords = [Ô][Ô]


For i = 0 To iWords
strWords = strWords & aWords(i)
Next i
[ô]Get Width of Blank Space
xSpace = iWidth - Printer.TextWidth(strWords)
[ô]Calculate Blank Space Between Words
xSpace = Int(xSpace / iWords)
[ô]Print Last Word Right Justified
Printer.CurrentX = xRight - Printer.TextWidth(aWords(iWords))
Printer.CurrentY = yPrint
Printer.Print aWords(iWords)
[ô]Print Words xSpace apart


For i = 0 To iWords - 1 [ô]We just printed the last word
[ô]Calculate xPrint
xPrint = xLeft


For j = 1 To i
xPrint = xPrint + Printer.TextWidth(aWords(j - 1)) + xSpace
Next j
Printer.CurrentX = xPrint
Printer.CurrentY = yPrint
Printer.Print aWords(i)
Next i
Loop
End Sub

MUITO OBRIGADO
Tópico encerrado , respostas não são mais permitidas