Programación General > Visual Basic 6.0 e inferiores

 Propiedades De Impresion

(1/2) > >>

arley:
Hola necesito que alguien me ayude con un codigo de visual basic de modo que al yo querer imprimir algo primero me muestre las propiedades de la impresora y pueda escoger tipo de papel, calidad de impresion, numero de copias y todo lo relacionado con dicha impresion les agradezco de antemano.

MUCHAS GRACIAS... :rolleyes:

cpmario:
Activa en componentes un control "Microsoft Common Dialog" y colócalo en una forma y dale el siguiente nombre cdlMain.
Después llamas a ese control con lo siguiente:


--- Código: Text ---    cdlMain.CancelError = True    cdlMain.Flags = cdlPDPrintSetup    cdlMain.ShowPrinter   :comp:

arley:

--- Cita de: "cpmario" --- Activa en componentes un control "Microsoft Common Dialog" y colócalo en una forma y dale el siguiente nombre cdlMain.
Después llamas a ese control con lo siguiente:


--- Código: Text ---    cdlMain.CancelError = True    cdlMain.Flags = cdlPDPrintSetup    cdlMain.ShowPrinter   :comp:
--- Fin de la cita ---
Muchas gracias por el codigo, pero sin embargo no me imprime lo que le digo en las propiedades si me puedes ayudar te lo agradezco. :D

cpmario:
Te proporciono una rutina que imprime un reporte. Te dará una idea de como usar los comandos de impresión.

--- Código: Text --- Sub PrintIncap(blnPrintDx As Boolean)    Dim strPr As String    Dim intCnt As Integer    Dim intPrintTab As Integer    Dim strTexto As String    On Error GoTo ErrorcmdPrint    cdlMain.CancelError = True    cdlMain.Flags = cdlPDPrintSetup    cdlMain.ShowPrinter    Screen.MousePointer = vbHourglass    cmdPrintIncap.Enabled = False    For intCnt = 1 To 3        strPr = strPr & vbCrLf    Next intCnt    Printer.Print strPr    Printer.Font = "Arial"    Printer.FontSize = 14    Printer.Font.Bold = True    intPrintTab = 12    Printer.Print Tab(intPrintTab); "INSTITUTO MEXICANO DEL SEGURO SOCIAL"    Printer.Print Tab(intPrintTab); "Reporte de Datos de Incapacidad"    Printer.Print    Printer.Font = "Courier New"    Printer.FontSize = 10    Printer.Font.Bold = False    intPrintTab = 15    Printer.Print Tab(intPrintTab); "Número de serie: ";: Printer.Font.Bold = True: Printer.Print txtSerie: Printer.Font.Bold = False    Printer.Print Tab(intPrintTab); "Nombre de paciente: ";: Printer.Font.Bold = True: Printer.Print txtNombre.Text: Printer.Font.Bold = False    Printer.Print Tab(intPrintTab); "Afiliación: ";: Printer.Font.Bold = True: Printer.Print txtAfiliación.Text: Printer.Font.Bold = False    Printer.Print Tab(intPrintTab); "Médicos: " & txtMédicos.Text    Printer.Print Tab(intPrintTab); "Matrícula: " & txtMatrícula.Text    If blnPrintDx Then        strTexto = WordWrap(txtDiagnóstico.Text, 60)        Printer.Print Tab(intPrintTab); "Diagnóstico: " & strTexto    End If    Printer.Print Tab(intPrintTab); "Días de incapacidad: ";: Printer.Font.Bold = True: Printer.Print txtDiasIncap.Text: Printer.Font.Bold = False    Printer.Print&#59; Tab(intPrintTab); "A partir de: ";: Printer.Font.Bold = True: Printer.Print txtAPartir.Text: Printer.Font.Bold = False    Printer.Print&#59; Tab(intPrintTab); "Fecha de expedición: " & txtFechaExpedición.Text    Printer.Print Tab(intPrintTab); "Fecha de captura: " & txtFechaCaptura.Text    If txtRamo.Text = "EG" Then        strPr = "ENFERMEDAD GENERAL"    ElseIf txtRamo.Text = "MA" Then        strPr = "MATERNIDAD"    ElseIf txtRamo.Text = "RT" Then        strPr = "RIESGO DE TRABAJO"    ElseIf txtRamo.Text = "PR" Then        strPr = "PROBABLE RIESGO DE TRABAJO"    End If    Printer.Print Tab(intPrintTab); "Ramo: " & strPr    If txtMaternidad.Text = "PRE" Then        strPr = "PRENATAL"    ElseIf txtRamo.Text = "ENL" Then        strPr = "ENLACE"    ElseIf txtRamo.Text = "POS" Then        strPr = "POSNATAL"    Else        strPr = ""    End If    If strPr <> "" Then        Printer.Print Tab(intPrintTab); "Maternidad: " & strPr    End If    If txtTipo.Text = "INI" Then        strPr = "INICIAL"    ElseIf txtTipo.Text = "SUB" Then        strPr = "SUBSECUENTE"    ElseIf txtTipo.Text = "REC" Then        strPr = "RECAÍDA"    ElseIf txtTipo.Text = "CAN" Then        strPr = "CANCELADA"    End If    Printer.Print Tab(intPrintTab); "Tipo: " & strPr    If blnPrintDx Then        Printer.Print Tab(intPrintTab); "Comentario: " & txtComentario.Text    End If    If txtRamo.Text = "PR" Or txtRamo.Text = "RT" Then        Printer.Print Tab(intPrintTab); "ST1: " & txtST1.Text        Printer.Print Tab(intPrintTab); "ST2: " & txtST2.Text        Printer.Print Tab(intPrintTab); "Nota médica: " & txtNota.Text    End If    If blnPrintDx Then        Printer.Print Tab(intPrintTab); "Observaciones: " & txtObsv.Text    End If    If txtPuesto.Text <> "" Then        Printer.Print Tab(intPrintTab); "Puesto de trabajo: " & txtPuesto.Text    End If    If txtIMSS.Text <> "" Then        Printer.Print Tab(intPrintTab); "Trabajador IMSS: " & txtIMSS.Text    End If       Printer.EndDoc    cmdPrintIncap.Enabled = True    Screen.MousePointer = vbDefaultExit SubErrorcmdPrint:    If Err <> cdlCancel Then        MsgBox "Error al imprimir datos. Revise su impresora." & vbCrLf & Err.Description, vbCritical, gstrAppTitle        Err.Clear    End If    cmdPrintIncap.Enabled = True    Screen.MousePointer = vbDefaultExit SubEnd Sub Espero te sirva.
 :comp:

arley:

--- Cita de: "cpmario" --- Te proporciono una rutina que imprime un reporte. Te dará una idea de como usar los comandos de impresión.

--- Código: Text --- Sub PrintIncap(blnPrintDx As Boolean)    Dim strPr As String    Dim intCnt As Integer    Dim intPrintTab As Integer    Dim strTexto As String    On Error GoTo ErrorcmdPrint    cdlMain.CancelError = True    cdlMain.Flags = cdlPDPrintSetup    cdlMain.ShowPrinter    Screen.MousePointer = vbHourglass    cmdPrintIncap.Enabled = False    For intCnt = 1 To 3        strPr = strPr & vbCrLf    Next intCnt    Printer.Print strPr    Printer.Font = "Arial"    Printer.FontSize = 14    Printer.Font.Bold = True    intPrintTab = 12    Printer.Print Tab(intPrintTab); "INSTITUTO MEXICANO DEL SEGURO SOCIAL"    Printer.Print Tab(intPrintTab); "Reporte de Datos de Incapacidad"    Printer.Print    Printer.Font = "Courier New"    Printer.FontSize = 10    Printer.Font.Bold = False    intPrintTab = 15    Printer.Print Tab(intPrintTab); "Número de serie: ";: Printer.Font.Bold = True: Printer.Print txtSerie: Printer.Font.Bold = False    Printer.Print Tab(intPrintTab); "Nombre de paciente: ";: Printer.Font.Bold = True: Printer.Print txtNombre.Text: Printer.Font.Bold = False    Printer.Print Tab(intPrintTab); "Afiliación: ";: Printer.Font.Bold = True: Printer.Print txtAfiliación.Text: Printer.Font.Bold = False    Printer.Print Tab(intPrintTab); "Médicos: " & txtMédicos.Text    Printer.Print Tab(intPrintTab); "Matrícula: " & txtMatrícula.Text    If blnPrintDx Then        strTexto = WordWrap(txtDiagnóstico.Text, 60)        Printer.Print Tab(intPrintTab); "Diagnóstico: " & strTexto    End If    Printer.Print Tab(intPrintTab); "Días de incapacidad: ";: Printer.Font.Bold = True: Printer.Print txtDiasIncap.Text: Printer.Font.Bold = False    Printer.Print; Tab(intPrintTab); "A partir de: ";: Printer.Font.Bold = True: Printer.Print txtAPartir.Text: Printer.Font.Bold = False    Printer.Print; Tab(intPrintTab); "Fecha de expedición: " & txtFechaExpedición.Text    Printer.Print Tab(intPrintTab); "Fecha de captura: " & txtFechaCaptura.Text    If txtRamo.Text = "EG" Then        strPr = "ENFERMEDAD GENERAL"    ElseIf txtRamo.Text = "MA" Then        strPr = "MATERNIDAD"    ElseIf txtRamo.Text = "RT" Then        strPr = "RIESGO DE TRABAJO"    ElseIf txtRamo.Text = "PR" Then        strPr = "PROBABLE RIESGO DE TRABAJO"    End If    Printer.Print Tab(intPrintTab); "Ramo: " & strPr    If txtMaternidad.Text = "PRE" Then        strPr = "PRENATAL"    ElseIf txtRamo.Text = "ENL" Then        strPr = "ENLACE"    ElseIf txtRamo.Text = "POS" Then        strPr = "POSNATAL"    Else        strPr = ""    End If    If strPr <> "" Then        Printer.Print Tab(intPrintTab); "Maternidad: " & strPr    End If    If txtTipo.Text = "INI" Then        strPr = "INICIAL"    ElseIf txtTipo.Text = "SUB" Then        strPr = "SUBSECUENTE"    ElseIf txtTipo.Text = "REC" Then        strPr = "RECAÍDA"    ElseIf txtTipo.Text = "CAN" Then        strPr = "CANCELADA"    End If    Printer.Print Tab(intPrintTab); "Tipo: " & strPr    If blnPrintDx Then        Printer.Print Tab(intPrintTab); "Comentario: " & txtComentario.Text    End If    If txtRamo.Text = "PR" Or txtRamo.Text = "RT" Then        Printer.Print Tab(intPrintTab); "ST1: " & txtST1.Text        Printer.Print Tab(intPrintTab); "ST2: " & txtST2.Text        Printer.Print Tab(intPrintTab); "Nota médica: " & txtNota.Text    End If    If blnPrintDx Then        Printer.Print Tab(intPrintTab); "Observaciones: " & txtObsv.Text    End If    If txtPuesto.Text <> "" Then        Printer.Print Tab(intPrintTab); "Puesto de trabajo: " & txtPuesto.Text    End If    If txtIMSS.Text <> "" Then        Printer.Print Tab(intPrintTab); "Trabajador IMSS: " & txtIMSS.Text    End If       Printer.EndDoc    cmdPrintIncap.Enabled = True    Screen.MousePointer = vbDefaultExit SubErrorcmdPrint:    If Err <> cdlCancel Then        MsgBox "Error al imprimir datos. Revise su impresora." & vbCrLf & Err.Description, vbCritical, gstrAppTitle        Err.Clear    End If    cmdPrintIncap.Enabled = True    Screen.MousePointer = vbDefaultExit SubEnd Sub Espero te sirva.
 :comp:
--- Fin de la cita ---
Gracias por el codigo que me has enviado, pero hay un problema los cambios que hago en las propiedades de la impresora no se guardan ya que si selecciono que deseo varias copias iguales y que la impresion sea en borrador no lo hace sino que simplemente imprime una hoja normal.

Si me puedes ayudar te lo Agradezco. :D

Navegación

[0] Índice de Mensajes

[#] Página Siguiente

Ir a la versión completa