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

exporting A Crystal Report to word for from VB6

Status
Not open for further replies.

ctdapper

Programmer
Feb 13, 2001
22
US
I am unable to export a report created by crystal reports to a word doc through code alone. Vb code will only display it in the crystal reports preview. But I would like to have VB call it and save it with out user interface. Can this be done? If so how
 
Try this:
add a CrystalReport control (not the SmartViewer) to the form.

//////////////////////
CrystalReport1.ReportFileName = path and name of report
CrystalReport1.PrintFileType = crptText '(or crptWinWord )
CrystalReport1.PrintFileName = "C:\MyDoc\Test.doc"
CrystalReport1.PrintReport
/////////////////////////

Good luck.
 
Here is some modified code I have used

Dim myReport As New CrystalReport1

With myReport
.DiscardSavedData
.ReportTitle = "Title here"
.ExportOptions.FormatType = crEFTWordForWindows
.ExportOptions.DiskFileName = enter path here
.ExportOptions.DestinationType = crEDTDiskFile
.ExportOptions.ApplicationFileName = enter path here
.Export (False)
End With

This will export the report to word doc without user prompts. You might need to play around with the export options as my original code exported to html.

Hope this helps
DamoOz
 
mmr,

Forgot a line...

CrystalReport1.Destination = crptToFile

Works fine.
 
I am using the new CRAXDRT object in Crystal 8. My code looks like this:

General Declarations:
Public crApplication As New CRAXDRT.Application

Public Sub Export_To_Word

Dim crReport As CRAXDRT.Report

Set crReport = crApplication.OpenReport("MyReport.rpt")

With crReport
.ExportOptions.DestinationType = crEDTDiskFile
.ExportOptions.DiskFileName = "FileName.doc"
.ExportOptions.FormatType = crEFTWordForWindows

.Export False
End With

Set crReport = Nothing

End Sub

Probably just another way to do the same thing.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top