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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting CR8.5 to Pdf (using vb6)

Status
Not open for further replies.

jdixonct

Programmer
Mar 4, 2002
3
US
I have code snippet that will write out a word document from crystal reports. Does anyone know what changes would be needed to write out a pdf format instead of word?? Here is my code:

Dim app As Application
Dim report As report
Set app = CreateObject("Crystal.CRPE.Application")
Set report = app.OpenReport("C:\TEMP\ExportTest.rpt")
report.ExportOptions.DestinationType = 1 ' export to disk
report.ExportOptions.FormatType = 4
report.ExportOptions.DiskFileName = "C:/TEMP/PrintTest.doc"
report.Export False 'dont prompt user
 
The constant for pdf format is 31(crEFTPortableDocFormat)
It should be
report.ExportOptions.FormatType = 31
 
I have tried this

report.ExportOptions.FormatType = 31

and I get an error when I try executing that line.

Run-time Error 30012
"Invalid Enum Value"
 
You need to check your references -

* for an early bind using non-OCX controls: Under VB IDE click on Project/References and look for "Crystal Report 6/7/8 Report Engine" with a file reference pointing to CPEAUTH32.DLL.
*for a late bind (which I highly recomend): Simply create a new object with the following code -

Dim objCrystal as Object
Set objCrystal = CreateObject("Crystal.CrystalReport")

The reason I recommend it: a) your operating system does the dirty work of finding Crystal Report references...and b) Crystal Report has a dirty little secret - the DLL object has a memory leak - a big one - which is solved by late binding.
 
I had the reference to the Crystal Report 8 Engine in my VB Project. I removed the reference and tried late binding, but I got the same error message:

Run-time Error 30012
"Invalid Enum Value"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top