Jump to content

Trying to print crystal report to printer automatically


dmorand
 Share

Recommended Posts

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)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...