ghines
November 30th, 2008, 11:54 PM
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.
Can the .Preview method of the Report object operate asynchronously?
Or, is there a state property of the Report object ?
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
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.
Can the .Preview method of the Report object operate asynchronously?
Or, is there a state property of the Report object ?
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