| Junior 2005-05-20, 4:04 am |
| I have a code for customize paper size with CR 7 and VB 6.0, but each time i
send the report to the printer i see a dialog box counting pages and never
prints.
Any idea?
I took the example from
http://support.businessobjects.com/...es/c2005467.asp
******************* Declations code ******************
Type crDEVMODE
dmDriverVersion As Integer
' printer driver version number (usually not required)
#If Win16 Then
' add padding so it aligns the same way under both 16-and 32-bit
environments
pad1 As Integer
#End If
dmFields As Long
'flags indicating fields to modify (required)
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
End Type
Declare Function PEOpenEngine Lib "crpe32.dll" () As Integer
Declare Function PEOpenPrintJob Lib "crpe32.dll" (ByVal RptName$) As Integer
Declare Function PEOutputToPrinter Lib "crpe32.dll" (ByVal printJob%, ByVal
nCopies%) As Integer
Declare Function PEStartPrintJob Lib "crpe32.dll" (ByVal printJob%, ByVal
WaitOrNot%) As Integer
Declare Function PEClosePrintJob Lib "crpe32.dll" (ByVal printJob%) As Integer
Declare Sub PECloseEngine Lib "crpe32.dll" ()
Declare Function crPESelectPrinter Lib "crwrap32.dll" (ByVal printJob As
Integer, ByVal driverName As String, ByVal printerName As String, ByVal
portName As String, crmode As crDEVMODE) As Integer
' ********************** Code from the form *********************
Dim Job As Integer
Dim Result As Integer
Dim MyDevMode As crDEVMODE
' Open print engine
Result = PEOpenEngine()
' Open the selected report
Job = PEOpenPrintJob(App.Path & "\Cheque1.rpt")
MyDevMode.dmFields = DM_PAPERSIZE + DM_PAPERLENGTH + DM_PAPERWIDTH
MyDevMode.dmPaperSize = DMPAPER_USER ' or 256
MyDevMode.dmPaperLength = 254
MyDevMode.dmPaperWidth = 1004
' paper length and width in tenths of a mm (1 inch long, by 4 inches wide,
above)
Result = crPESelectPrinter(Job, driverName & vbNullChar, printerName &
vbNullChar, portName & vbNullChar, MyDevMode)
' ****************************************
**********
'‘ Specify the destination as printer
Result = PEOutputToPrinter(Job, 0)
'‘ Start the print job
Result = PEStartPrintJob(Job, 0)
'‘ Close the print job
PEClosePrintJob (Job)
'‘ Close the engine
PECloseEngine
|