Using Access VBA to convert Crystal Reports to Excel (1 Viewer)

mccoydo

New member
Local time
Today, 21:06
Joined
Apr 16, 2015
Messages
5
Hi Guys, Am not sure whether this belongs here or in the VBA forum. Have searched both but can't find an answer. Here goes anyway...

I've been given a set of crystal reports that I need to export to excel. I can do so individually using Crystal Reports Viewer but this is time consuming for multiple reports.

I'm trying to use Access 2013 VBA to do this. I think I have downloaded the correct VBA reference (craxdrt.dll). Code I'm using is below. Do you think I'm on the right track?

Note that I do not have the option to have the original reports exported in Excel format and that I cannot connect to Crystal itself. It is just the report outputs that I've access to.

Thanks in advance for your help.

'sDirectory, sFile & sPath aren't declared here to save space...

Private Sub ExportFile(sPath As String)
DoCmd.SetWarnings False

Dim CR As CRAXDRT.Application
Dim rep As CRAXDRT.report
Set CR = New CRAXDRT.Application
Set rep = CR.OpenReport(sPath)

Dim sFile As String
Dim sDirectory As String

sDirectory = fGetDirectory(sPath)
sFile = fGetFileName(sPath)


sFile = Left(fGetFileName(sPath), Len(fGetFileName(sPath)) - 4) & ".xlsx"

rep.SaveAs fGetDirectory(sPath) & sFile
rep.Close False
Set rep = Nothing

Debug.Print "created file " & sFile

CR.Quit
Set CR = Nothing

DoCmd.SetWarnings True

End Sub
 

kevlray

Registered User.
Local time
Today, 13:06
Joined
Apr 5, 2010
Messages
756
There should be a lot of information on using Crystal Reports with Visual Studio in .Net (You have to match the correct version of CR with VS). I have not heard of anybody trying to do anything with CR in VBA. Lots of luck.
 

mccoydo

New member
Local time
Today, 21:06
Joined
Apr 16, 2015
Messages
5
Thanks for the response kevlray.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom