I have an old project that used the GLOBAL32.BAS module in an Access 2003 project to run a Crystal 8 report and display to the screen.
I want to change the code below to automatically export this to a file instead of printing to a screen. I have not decided if I want it to be an XLS, DOC, or RPT file yet so it would also be great to know the parameters for each.
This function accepts and order number as a parameter.
==============================================================
Public Function PrintOrder(strOrder As String)
Dim Result%
Dim SelectionText$
Dim jobnum%
Dim SalesOrderWindowOptions As PEWindowOptions
On Error GoTo Err_PrintOrder
SelectionText$ = "{SO Master.ORDNUM_27} = '" & strOrder & "'"
Result% = PEOpenEngine()
If Result% = 0 Then
MsgBox "Could not start the report engine. Execution must halt.", vbOKOnly + vbCritical, "Serious Error"
End
End If
jobnum% = PEOpenPrintJob("C:\Reports\Order.rpt")
If jobnum% = 0 Then
MsgBox "Sales Order Report missing"
End If
Result% = PESetSelectionFormula(jobnum%, SelectionText$)
If Result% = 0 Then
MsgBox "Report may be damaged, changed, or missing. Check report file.", , "Report Problem"
End
End If
With SalesOrderWindowOptions
.StructSize = 26
.hasPrintSetupButton = 1
.hasCancelButton = 1
.hasExportButton = 1
.hasNavigationControls = 1
.hasPrintButton = 1
.hasZoomControl = 1
End With
Result% = PESetWindowOptions(jobnum%, SalesOrderWindowOptions)
Result% = PEOutputToWindow(jobnum%, "Sales Order" & Chr$(0), CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0)
Result% = PEStartPrintJob(jobnum%, True)
PEClosePrintJob (jobnum%)
Exit_PrintOrder:
Exit Function
Err_PrintOrder:
MsgBox Err.Description, , Err.Number
Resume Exit_PrintOrder
End Function
I want to change the code below to automatically export this to a file instead of printing to a screen. I have not decided if I want it to be an XLS, DOC, or RPT file yet so it would also be great to know the parameters for each.
This function accepts and order number as a parameter.
==============================================================
Public Function PrintOrder(strOrder As String)
Dim Result%
Dim SelectionText$
Dim jobnum%
Dim SalesOrderWindowOptions As PEWindowOptions
On Error GoTo Err_PrintOrder
SelectionText$ = "{SO Master.ORDNUM_27} = '" & strOrder & "'"
Result% = PEOpenEngine()
If Result% = 0 Then
MsgBox "Could not start the report engine. Execution must halt.", vbOKOnly + vbCritical, "Serious Error"
End
End If
jobnum% = PEOpenPrintJob("C:\Reports\Order.rpt")
If jobnum% = 0 Then
MsgBox "Sales Order Report missing"
End If
Result% = PESetSelectionFormula(jobnum%, SelectionText$)
If Result% = 0 Then
MsgBox "Report may be damaged, changed, or missing. Check report file.", , "Report Problem"
End
End If
With SalesOrderWindowOptions
.StructSize = 26
.hasPrintSetupButton = 1
.hasCancelButton = 1
.hasExportButton = 1
.hasNavigationControls = 1
.hasPrintButton = 1
.hasZoomControl = 1
End With
Result% = PESetWindowOptions(jobnum%, SalesOrderWindowOptions)
Result% = PEOutputToWindow(jobnum%, "Sales Order" & Chr$(0), CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0)
Result% = PEStartPrintJob(jobnum%, True)
PEClosePrintJob (jobnum%)
Exit_PrintOrder:
Exit Function
Err_PrintOrder:
MsgBox Err.Description, , Err.Number
Resume Exit_PrintOrder
End Function