Question Locked

Help with Vbscript and Crystal Reports

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi Everyone,

I'm trying to preview a Crystal Report using VBS, however the report just opens and
immediately closes.

The line report.Preview needs to execute and then wait until the report window closes.

How do I make the preview window remain open?

Code is below.

TIA

Greg

Dim sReportName 'As String
Dim PrintToScreen 'As Boolean
Dim iNumToPrint 'As Integer
Dim View1 'As CRPEAuto.View

Dim CRapp 'As CRPEAuto.Application
Dim report 'As CRPEAuto.report
Dim Window1 'As CRPEAuto.Window
Dim reportDb 'As CRPEAuto.Database
Dim reportTables 'As CRPEAuto.DatabaseTables
Dim reportTable 'As CRPEAuto.DatabaseTable
sReportName = "d:\rptcus\reports\myrpt.rpt"
iNumToPrint = 1
'Create an Application object with the Crystal Report Engine Automation
Server.
Set CRapp = WScript.CreateObject("Crystal.CRPE.Application")

Set report = CRapp.OpenReport(sReportName)

Set reportDb = report.Database
Set reportTables = reportDb.Tables
Set reportTable = reportTables.Item(1)

report.ParameterPromptingEnabled = True

Call reportTable.SetLogOnInfo("Opennet Custom Report") 'ODBC Connection to
DBF file

report.PrintWindowOptions.HasPrintSetupButton = True
report.PrintWindowOptions.HasPrintSetupButton = True
report.PrintWindowOptions.HasExportButton = True
report.PrintWindowOptions.HasSearchButton = True
report.PrintWindowOptions.HasCancelButton = True
report.PrintWindowOptions.HasCloseButton = True
report.PrintWindowOptions.HasRefreshButton = True
report.PrintWindowOptions.HasGroupTree = True
report.PrintWindowOptions.HasNavigationControls = True
report.PrintWindowOptions.HasProgressControls = True

report.Preview

On Error Resume Next
Set CRapp = Nothing
Set report = Nothing
Set reportDb = Nothing
Set reportTables = Nothing
Set reportTable = Nothing

4 replies

by gregeeh

I need a way of making the CPRE method halt at the command "report.Preview" until the window is closed.

No ideas anyone?

by gregeeh

Hi Jacky,

Thanks for the link however that example does not have to preview the report and keep the preview window open. It just gets the report and converts it to PDF.

Thanks anyhow.

This discussion is closed to new replies.