I have a routine to export Crystal Reports files to pdf. If I try to set the pdf file name automatically, I receive an error saying that the file is in use by another program. If I hard code the file name, the code works ok. That's the relevant code I am using:
spdffilename = "C:\Docs\MyFile.pdf"
sDestinationOptions.DiskFileName = spdffilename
oexportoptions = pReport.ExportOptions
With oexportoptions
.DestinationOptions = sDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
pReport.Export() 'Error occurs here
If I change the first line to:
spdffilename = System.IO.Path.GetFileNameWithoutExtension(pReport.FilePath) & ".pdf"
The code stops working when the export method runs. Can anyone see what is wrong in this line?
Thanks,
Robert


Reply With Quote