Sign in to follow this  
Followers 0
dmorand

Trying to print crystal report to printer automatically

1 post in this topic

I'm trying to print a report to a printer automatically when a user runs my script. I know I need to use the PrintToPrinter method, but when I call it I get an error: "The requested action with this object has failed." Has anyone gotten the crystal functions to work with autoit?

Dim $ReportName
Dim $CRApp
Dim $CrystalReport

$ReportName = "C:\Transfer\Missing_Documents_ED_Encounters.rpt"
$CRApp = ObjCreate("CrystalRuntime.Application.10")

If $CRApp = 0 Then
MsgBox(0, "Error", "Could not create CrystalRuntime Object")
Exit
EndIf

$CrystalReport = $CRApp.OpenReport($ReportName)
If $CrystalReport = 0 Then
    MsgBox(0, "Error", "Could not open report: " & $sReportName)
    Exit
Else
    MsgBox(0,"Success","Report Opened")
EndIf

$CrystalReport.PrintToPrinter(1,False,0,0)

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0