pcdev
asked on
vb crystal ocx printing landscape
Please help
I need to be able to tell the crystl32.ocx
to print a report designed in landscape in landscape.
But the view/print is always landscape
Is there a hidden function paramter something that I cannot find.
Otherwise what is the alternative, i have done 168 reports and do not want to change them.
Also they have parameter fields which need to be set at runtime - have done this OK
many thanks
paul cooper
paul@pcdevelopments.co.uk
I need to be able to tell the crystl32.ocx
to print a report designed in landscape in landscape.
But the view/print is always landscape
Is there a hidden function paramter something that I cannot find.
Otherwise what is the alternative, i have done 168 reports and do not want to change them.
Also they have parameter fields which need to be set at runtime - have done this OK
many thanks
paul cooper
paul@pcdevelopments.co.uk
ASKER
Thanks for you comments on experts exchange
however using crRpt.PaperOrientation = crLandscape
and crRpt.PaperOrientation = 2
I get
438 - Object doesn't support this property or method
Any other options?
VB6
SP5
Crystal OCX v 8.0.0.4 from 8.5 developer
many thanks
however using crRpt.PaperOrientation = crLandscape
and crRpt.PaperOrientation = 2
I get
438 - Object doesn't support this property or method
Any other options?
VB6
SP5
Crystal OCX v 8.0.0.4 from 8.5 developer
many thanks
ASKER
Thanks for you comments on experts exchange
however using crRpt.PaperOrientation = crLandscape
and crRpt.PaperOrientation = 2
I get
438 - Object doesn't support this property or method
Any other options?
VB6
SP5
Crystal OCX v 8.0.0.4 from 8.5 developer
many thanks
however using crRpt.PaperOrientation = crLandscape
and crRpt.PaperOrientation = 2
I get
438 - Object doesn't support this property or method
Any other options?
VB6
SP5
Crystal OCX v 8.0.0.4 from 8.5 developer
many thanks
can you post your code for when you open the report
ASKER
Private Sub cmdPrint_Click()
On Error GoTo cmdPrint_Click_Error
' MsgBox "This program is in debug mode, please be patient"
Dim iFormulaCount As Integer
Dim iSplit As Integer
sReportConnect = "dsn=" & sDSN & _
";UID=" & sUser & _
";Pwd=" & sPassword
'Get Report Name
Dim sReportFileName As String
List1.ListIndex = 0
sReportFileName = List1
'Get Printer Name
Dim sReportPrinterName As String
List1.ListIndex = 1
sReportPrinterName = List1
'Get Printer Driver
Dim sReportPrinterDriver As String
List1.ListIndex = 2
sReportPrinterDriver = List1
Dim iParamNum As Integer
With CR1
.ReportFileName = sReportFileName
'.SelectionFormula = sSQL
.Connect = sReportConnect
.PrinterName = sReportPrinterName
.PrinterPort = sReportPrinterName
.PrinterDriver = sReportPrinterName
'.Orientation = 2
.PaperOrientation = 2
If chkPreview = vbChecked Then
.Destination = crptToWindow
Else
.Destination = crptToPrinter
End If
' .DiscardSavedData = False
'Blank Formulas
For iFormulaCount = 0 To 99
.ParameterFields(iFormulaC ount) = ""
Next
'Get Parameters
iParamNum = 0
iSplit = 1
Do Until List1.ListIndex = List1.ListCount - 1
List1.ListIndex = List1.ListIndex + 1
pArray = Split(List1, "=", , vbTextCompare)
For Each p In pArray
If iSplit = 2 Then
.ParameterFields(iParamNum ) = "Param" & iParamNum + 1 & ";" & p & ";True"
iParamNum = iParamNum + 1
iSplit = 1
Else
iSplit = iSplit + 1
End If
Next
Loop
' .Formulas(iFormula) = "Form" & iFormula + 1 & " = '" & List1 & "'"
' .ParameterFields(0) = "a1;Hello World;True"
.Action = 1
End With
' End
Exit Sub
cmdPrint_Click_Error:
MsgBox Err & " - " & error & " - frmScanPrint"
Exit Sub
End Sub
On Error GoTo cmdPrint_Click_Error
' MsgBox "This program is in debug mode, please be patient"
Dim iFormulaCount As Integer
Dim iSplit As Integer
sReportConnect = "dsn=" & sDSN & _
";UID=" & sUser & _
";Pwd=" & sPassword
'Get Report Name
Dim sReportFileName As String
List1.ListIndex = 0
sReportFileName = List1
'Get Printer Name
Dim sReportPrinterName As String
List1.ListIndex = 1
sReportPrinterName = List1
'Get Printer Driver
Dim sReportPrinterDriver As String
List1.ListIndex = 2
sReportPrinterDriver = List1
Dim iParamNum As Integer
With CR1
.ReportFileName = sReportFileName
'.SelectionFormula = sSQL
.Connect = sReportConnect
.PrinterName = sReportPrinterName
.PrinterPort = sReportPrinterName
.PrinterDriver = sReportPrinterName
'.Orientation = 2
.PaperOrientation = 2
If chkPreview = vbChecked Then
.Destination = crptToWindow
Else
.Destination = crptToPrinter
End If
' .DiscardSavedData = False
'Blank Formulas
For iFormulaCount = 0 To 99
.ParameterFields(iFormulaC
Next
'Get Parameters
iParamNum = 0
iSplit = 1
Do Until List1.ListIndex = List1.ListCount - 1
List1.ListIndex = List1.ListIndex + 1
pArray = Split(List1, "=", , vbTextCompare)
For Each p In pArray
If iSplit = 2 Then
.ParameterFields(iParamNum
iParamNum = iParamNum + 1
iSplit = 1
Else
iSplit = iSplit + 1
End If
Next
Loop
' .Formulas(iFormula) = "Form" & iFormula + 1 & " = '" & List1 & "'"
' .ParameterFields(0) = "a1;Hello World;True"
.Action = 1
End With
' End
Exit Sub
cmdPrint_Click_Error:
MsgBox Err & " - " & error & " - frmScanPrint"
Exit Sub
End Sub
why not use CRAXDRT (projects/references/cryst al activex designer runtime library)
then you can do something like:
Dim CR as new CRAXDRT.Application
Dim myRpt as CRAXDRT.Report
set myRpt = CR.openReport("<file name>")
myRpt.EnableParameterPromp ting = False
'' pass your parameters in
myRpt.ParameterFieldDefini tions.Item (<index>). setCurrent Value "<value>"
'' set printer orientaiton
myRpt.PaperOrientation = crLandscape
myRpt.PrintOut
then you can do something like:
Dim CR as new CRAXDRT.Application
Dim myRpt as CRAXDRT.Report
set myRpt = CR.openReport("<file name>")
myRpt.EnableParameterPromp
'' pass your parameters in
myRpt.ParameterFieldDefini
'' set printer orientaiton
myRpt.PaperOrientation = crLandscape
myRpt.PrintOut
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Mate your a diamond, will do this and let you know.
Just always stuck with the OCX coz it worked in the past
Many thanks
Job well done and very quickly
Paul Cooper
paul@pcdevelopments.co.uk
Just always stuck with the OCX coz it worked in the past
Many thanks
Job well done and very quickly
Paul Cooper
paul@pcdevelopments.co.uk
PaperOrientation - CRPaperOrientation. Gets or sets the current printer paper orientation. For the default printer, crDefaultPaperOrientation is returned. Read/Write Can be written only when formatting idle.
crDefaultPaperOrientation 0
crLandscape 2
crPortrait 1