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

Printing slows when called from VBA

Status
Not open for further replies.

kbieber

MIS
Aug 14, 2000
118
0
0
US
I have a report which prints within 1-2 seconds when the selection criteria is specified within the report. However, when the selection value is passed from VBA, the run time increases to at least 30 seconds. I know its passing the right value because the 2 reports print identically. Why is there such a discrepancy?


Function PrintCrystalShopOrder()

Dim crpApplication As New CRPEAuto.Application
Dim crpReport As CRPEAuto.Report
Dim crpFFDs As FormulaFieldDefinitions
Dim crpFFD As FormulaFieldDefinition
Dim crporder As String
Dim loopCnt As Integer

crporder = Format(SaveShopOrd, "00000000")

Set crpReport = crpApplication.OpenReport("M:\crystal\meritec rpts\SFRLPPRTSQLrev4test.rpt")
Set crpFFDs = crpReport.FormulaFields
Set crpFFD = crpFFDs.item(14) 'order number

crpFFD.Text = Chr(34) & crporder & Chr(34)
crpReport.PrintOut

Set crpReport = Nothing
 
Dear Kbieber,

what you do here:

Dim crpApplication As New CRPEAuto.Application
...
Set crpReport = crpApplication.OpenReport("M:\crystal\meritec rpts\SFRLPPRTSQLrev4test.rpt")


is creating a new instance of the CRPEAuto.Application.
Which is (as I assume) already opened when you do the report manually.

If you have an open instance when you run the vba srcipt then you should try to get that one (somewhat currentInstance).


I would never use the following like that.
Dim crpApplication As New CRPEAuto.Application

I would allways code

Dim crpApplication As CRPEAuto.Application
set crpApplication = new crpeAuto.Application

so you know you create a new instance and when.

regards

Astrid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top