Programación General > Visual Basic para principiantes

 Impresion

(1/1)

PAPELUCHO:
Hola estimados amigos
Tengo el siguiente Problema, en un form tengo un boton para imprimir con el siguiente codigo :

Private Sub Btnimprimir_Click()
Printer.ScaleMode = vbCentimeters
Printer.PaperSize = vbPRPSFolio
Printer.FontName = "COURIER NEW "
Printer.FontSize = 12
Printer.FontBold = True
Printer.CurrentX = 2.5
Printer.CurrentY = 2.5
Printer.Print NRO_CARGO

Printer.CurrentX = 1.5
Printer.CurrentY = 3.5
Printer.Print FE_CARGO

Printer.CurrentX = 1
Printer.CurrentY = 5.5
Printer.Print NOM

Printer.CurrentX = 11
Printer.CurrentY = 5.7
Printer.Print RUT

Printer.CurrentX = 1
Printer.CurrentY = 6.8
Printer.Print DIRE

Printer.CurrentX = 10
Printer.CurrentY = 6.8
Printer.Print CIU

Printer.CurrentX = 16
Printer.CurrentY = 2.2
Printer.Print DCTO

Printer.CurrentX = 17
Printer.CurrentY = 3.2
Printer.Print NRO_DCTO

Printer.CurrentX = 16.8
Printer.CurrentY = 4
Printer.Print FE_DCTO

Printer.CurrentX = 16.3
Printer.CurrentY = 15
Printer.Print CTA1

Printer.CurrentX = 17.7
Printer.CurrentY = 15
Printer.Print VAL_CTA1

Printer.CurrentX = 16.3
Printer.CurrentY = 15.8
Printer.Print CTA2

Printer.CurrentX = 17.7
Printer.CurrentY = 15.8
Printer.Print VAL_CTA2

Printer.CurrentX = 4.5
Printer.CurrentY = 21.7
Printer.Print RESOL

Printer.CurrentX = 8.5
Printer.CurrentY = 21.7
Printer.Print FE_RESOL

Printer.CurrentX = 17.7
Printer.CurrentY = 20.7
Printer.Print TOTAL

Printer.CurrentX = 13
Printer.CurrentY = 29
Printer.Print FUNCIONARIO

Printer.CurrentX = 1.5
Printer.CurrentY = 8.5
imprimeLineas MOTIVO, 70

Printer.EndDoc

End Sub

y en un modulo esta funcion para imprimir lo que contiene el TEXT MOTIVO, ya que este esta con propiedad mulltiline= True

Public Sub imprimeLineas(Texto As Object, Linea As Integer)
    Dim Bloque As String
    'Numero de caracteres = NumC
    'Numero de Bloques = NumB
    Dim I As Integer
   
    Dim NumC, NumB As Integer
    NumC = Len(Texto.Text)
    If NumC > Linea Then
        NumB = NumC \ Linea
        For I = 0 To NumB
            Texto.SelStart = (Linea * I)
            Texto.SelLength = Linea
            Bloque = Texto.SelText
       
            Printer.Print Bloque
        Next I
    Else
          Printer.Print Texto.Text
    End If
    Printer.EndDoc
End Sub


El problema se sucita que al imprimir el campo MOTIVO la primera linea lo hace respetando el margen asignado Printer.CurrentX = 1.5  
                                              Printer.CurrentY = 8.5

PERO AL IMPRIMIR LA SEGUNDA LINEA Y LAS SIGUIENTES SE DESCUADRA YA QUE EMPIEZA A IMPRIMIR CASI EN EL BORDE IZQUIERDO DE LA HOJA,

¿ Como lo puedo hacer para que me siga imprimiendo la 2da y posteriorers lineas con los margenes ya dados y nos se descuadre?

Si me pueden echar una manito
De antemano muchas gracias

ArKaNtOs:
mira lo que tienes que hacer es lo siguiente, en vez de hacer esto:


--- Código: Text ---Printer.CurrentX = 1.5Printer.CurrentY = 8.5imprimeLineas MOTIVO, 70 
debes de tener algo asi

--- Código: Text --- 'Sin poner los Printer.currenx y currenty, ya que estos solo con un campo a la vezimprimeLineas MOTIVO, 70printer.enddoc.... Dim NumC, NumB As IntegerNumC = Len(Texto.Text)If NumC > Linea ThenNumB = NumC \ LineaFor I = 0 To NumBTexto.SelStart = (Linea * I)Texto.SelLength = LineaBloque = Texto.SelText printer.currentx=1.5printer.currenty=8.5 + lineaPrinter.Print BloqueNextElse  printer.currentx=1.5printer.currenty=8.5Printer.Print Texto.TextEnd If ' Printer.EndDoc no va ya que pones uno despues de llamar al sub  

PAPELUCHO:
ESTIMADO ARKANTOS

LO REALICE COMO LO SEÑALAS PERO AHORA EL PROBLEMA
ES QUE LA IMPRESION DE EL TEXT MOTIVO NO SALE EN EL MARGEN
SEÑALADO SINO QUE AL FINAL DE LA HOJA UNA LINEA Y LA OTRA LINEA
SALE EN OTRA HOJA AL FINAL TAMBIEN.

DE ANTEMANO MUCHAS GRACIAS POR LA AYUDA PRESTADA.-

ArKaNtOs:
Quitaste los enddoc repetidos?, esperame mañana te envio un codigo optimizado del tuyo es que ahora toy de paso :P jejeje

ArKaNtOs:
No voy a decir que este optimizado pero pues asi debe de funcionar jejejeje

Private Sub Btnimprimir_Click()
Printer.ScaleMode = vbCentimeters
Printer.PaperSize = vbPRPSFolio
Printer.FontName = "COURIER NEW "
Printer.FontSize = 12
Printer.FontBold = True
Printer.CurrentX = 2.5
Printer.CurrentY = 2.5
Printer.Print NRO_CARGO

Printer.CurrentX = 1.5
Printer.CurrentY = 3.5
Printer.Print FE_CARGO

Printer.CurrentX = 1
Printer.CurrentY = 5.5
Printer.Print NOM

Printer.CurrentX = 11
Printer.CurrentY = 5.7
Printer.Print RUT

Printer.CurrentX = 1
Printer.CurrentY = 6.8
Printer.Print DIRE

Printer.CurrentX = 10
Printer.CurrentY = 6.8
Printer.Print CIU

Printer.CurrentX = 16
Printer.CurrentY = 2.2
Printer.Print DCTO

Printer.CurrentX = 17
Printer.CurrentY = 3.2
Printer.Print NRO_DCTO

Printer.CurrentX = 16.8
Printer.CurrentY = 4
Printer.Print FE_DCTO

Printer.CurrentX = 16.3
Printer.CurrentY = 15
Printer.Print CTA1

Printer.CurrentX = 17.7
Printer.CurrentY = 15
Printer.Print VAL_CTA1

Printer.CurrentX = 16.3
Printer.CurrentY = 15.8
Printer.Print CTA2

Printer.CurrentX = 17.7
Printer.CurrentY = 15.8
Printer.Print VAL_CTA2

Printer.CurrentX = 4.5
Printer.CurrentY = 21.7
Printer.Print RESOL

Printer.CurrentX = 8.5
Printer.CurrentY = 21.7
Printer.Print FE_RESOL

Printer.CurrentX = 17.7
Printer.CurrentY = 20.7
Printer.Print TOTAL

Printer.CurrentX = 13
Printer.CurrentY = 29
Printer.Print FUNCIONARIO

Printer.CurrentX = 1.5
Printer.CurrentY = 8.5

j=0
For i = 1 To Len(Textto)
    If i mod 70=0 Then
        printer.currentx=1.5
        printer.currenty=8.5 + j
        Printer.Print s
        s = ""
        j = 0
    Else
        s = s + Mid(Texto, i, 1)
    End If
Next

Printer.EndDoc
end sub

Navegación

[0] Índice de Mensajes

Ir a la versión completa