imprimir en cualquier impresora con cr9
Os diré lo que hago, a ver si me podeis decir que hago mal.
Las instrucciones principales que hay son estas:
Siempre sale por la predeterminada, y aunque en driverPRN, devicePRN, portPRN se pongan valores inventados no da error pero sale por la predet.
Dim crxAplicacion As New CRAXDRT.Application
Dim Report As CRAXDRT.Report
'Busca la impresora deseada entre las que hay en el sistema para extraer el puerto y el driver
For Each X In Printers
If imX.DeviceName = impresora Then
devicePRN = imX.DeviceName
driverPRN = imX.DriverName
portPRN = imX.Port
If Left(devicePRN, 2) = "\" Then ' extrae el nombre de la impresora sin la ruta. Con el ocx no hacía falta hacerlo
Posi = InStr(3, devicePRN, "", 1)
devicePRN = Mid(devicePRN, Posi + 1)
End If
Exit For
End If
Next
Set Report = crxAplicacion.OpenReport(Reporte, 1)
Set DBTable = Report.Database.Tables(1)
Report.SelectPrinter driverPRN, devicePRN, portPRN
Report.PrintOut False, numero, False
Report.PrinterSetup (0) ' si se le pone esto si funciona pero no es lo que quería pues el nombre de la impresora ya se ha preguntado antes
¿como funciona exactamente el Report.SelectPrinter??
Las instrucciones principales que hay son estas:
Siempre sale por la predeterminada, y aunque en driverPRN, devicePRN, portPRN se pongan valores inventados no da error pero sale por la predet.
Dim crxAplicacion As New CRAXDRT.Application
Dim Report As CRAXDRT.Report
'Busca la impresora deseada entre las que hay en el sistema para extraer el puerto y el driver
For Each X In Printers
If imX.DeviceName = impresora Then
devicePRN = imX.DeviceName
driverPRN = imX.DriverName
portPRN = imX.Port
If Left(devicePRN, 2) = "\" Then ' extrae el nombre de la impresora sin la ruta. Con el ocx no hacía falta hacerlo
Posi = InStr(3, devicePRN, "", 1)
devicePRN = Mid(devicePRN, Posi + 1)
End If
Exit For
End If
Next
Set Report = crxAplicacion.OpenReport(Reporte, 1)
Set DBTable = Report.Database.Tables(1)
Report.SelectPrinter driverPRN, devicePRN, portPRN
Report.PrintOut False, numero, False
Report.PrinterSetup (0) ' si se le pone esto si funciona pero no es lo que quería pues el nombre de la impresora ya se ha preguntado antes
¿como funciona exactamente el Report.SelectPrinter??
