Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting to PDF through Crystal OCX

Status
Not open for further replies.

MattN

Programmer
Jan 21, 2002
29
GB
I am working with VB6 and CR 8.5

When working with the CR preview pane I can manually select export to disk.... PDF format.

However, the OCX does not allow me to select PDF format through code. Why is this?

Can anyone help?

Regards

Matt N
 
I was planning to attempt to do this shortly, so I don't have an answer - just the same question.

Unless someone has an answer, I guess I will be trying to use the RDC instead of the OCX. Has anyone tried to export to PDF using the RDC(using code)?

In any case, I want to reply so I can be notified of answers on this thread.
 
I experienced this very same problem. In VB you need to work with the CR engine directly. After a lot of poking around and reading the below works for me.

'References
'Crystal Reports Export
'Crystal Reports Engine
'Crystal Reports Library

'In this case I'm using a rpt file that
'has been designed using Active Data (Field Definitions Only) as the datasource
'and setting the datasource in code.

Dim crxappl As New CRAXDDRT.Application
Dim crxParamDef As CRAXDDRT.ParameterFieldDefinition
Dim crxParamDefs As CRAXDDRT.ParameterFieldDefinitions
Dim crxrep As CRAXDDRT.Report

Dim bywhat As String 'Will become parameter to be passed

Set crxrep = crxappl.OpenReport(App.Path & "\Reports\" & "MyReport.rpt")
Set crxParamDefs = crxrep.ParameterFields
For Each crxParamDef In crxParamDefs 'Parameters
With crxParamDef
Select Case .ParameterFieldName
Case "StartDate"
.AddCurrentValue (Format(DTPicker1(0).Value, "dd-mmm-yyyy"))
Case "EndDate"
.AddCurrentValue (Format(DTPicker1(1).Value, "dd-mmm-yyyy"))
Case "User"
.AddCurrentValue (UCase(UserName))
Case "SalesReps"
.AddCurrentValue (selected_reps)
Case "p_Group"
.AddCurrentValue (bywhat)
End Select
End With
Next crxParamDef
crxrep.Database.SetDataSource clsrs.t_rs, 3
crxrep.ExportOptions.DiskFileName = "e:\temp\pdf\" & outputname & ".pdf"
crxrep.ExportOptions.DestinationType = crEDTDiskFile
crxrep.ExportOptions.FormatType = crEFTPortableDocFormat
crxrep.Export False


Set crxParamDefs = Nothing
Set crxrep = Nothing
Set crxappl = Nothing
Exit Sub
 
A really first class posting.

Thanks for your help Natchocat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top