u8semaj
asked on
Using PrintReport over the web
I am using the following code in a web page to send the report directly to the printer. The code works on some machines but not on others. I get the error "ActiveX component can't create object 'WebReportBroker.WebReport Broker'" on the machines that it doesn't work.
Viewing the report with the activeX viewer works fine. The difference is that it uses WebReportBroker9 and WebReportSource9. If I try to use that code in my print page, the page loads but the printer dialog never shows.
I am using Crystal Reports 9 on my web server with IIS 5 on Windows 2000.
Any help would be appreciated.
Thanks
<HTML>
<HEAD>
<TITLE>Please Select a Printer</TITLE>
</HEAD>
<BODY BGCOLOR=C6C6C6>
<OBJECT ID="CRViewer"
CLASSID="CLSID:2DEF4530-8C E6-41c9-84 B6-A54536C 90213"
WIDTH=1% HEIGHT=1%
CODEBASE="/crystalreportvi ewers/acti veXViewer/ activexvie wer.cab#Ve rsion=9,2, 0,528" VIEWASTEXT>
<PARAM NAME="EnableRefreshButton" VALUE=0>
<PARAM NAME="EnableGroupTree" VALUE=0>
<PARAM NAME="DisplayGroupTree" VALUE=0>
<PARAM NAME="EnablePrintButton" VALUE=1>
<PARAM NAME="EnableExportButton" VALUE=0>
<PARAM NAME="EnableDrillDown" VALUE=0>
<PARAM NAME="EnableSearchControl" VALUE=0>
<PARAM NAME="EnableAnimationContr ol" VALUE=0>
<PARAM NAME="EnableZoomControl" VALUE=0>
</OBJECT>
<SCRIPT LANGUAGE="VBScript">
<!--
dim timer
dim printerTimer
dim pageOne
PageOne = True
Sub window_onLoad()
Page_Initialize()
End Sub
Sub Page_Initialize
Dim webBroker
Set webBroker = CreateObject("WebReportBro ker.WebRep ortBroker" )
if ScriptEngineMajorVersion < 2 then
window.alert "IE 3.02 users on NT4 need to get the latest version of VBScript or install IE 4.01 SP1. IE 3.02 users on Win95 need DCOM95 and latest version of VBScript, or install IE 4.01 SP1. These files are available at Microsoft's web site."
CRViewer.ReportName = Location.Href
else
Dim webSource
Set webSource = CreateObject("WebReportSou rce.WebRep ortSource" )
webSource.ReportSource = webBroker
webSource.URL = "rptserver.asp"
webSource.PromptOnRefresh = True
CRViewer.ReportSource = webSource
end if
CRViewer.ViewReport
End Sub
Sub CRViewer_DownloadFinished( byval downloadType)
if downloadType = 1 and PageOne then
PageOne = False
timer = window.settimeout("OnMyTim eOut",1000 )
end if
end sub
Sub OnMyTimeOut()
if not CRViewer.IsBusy then
window.ClearTimeout(timer)
'window.alert "My timeout"'
CRViewer.PrintReport
printerTimer = window.SetTimeOut("OnPrint erTimeOut" , 1000)
end if
end sub
Sub OnPrinterTimeOut()
if not CRViewer.IsBusy then
window.ClearTimeOut(printe rTimer)
' window.History.Back'
end if
end sub
-->
</SCRIPT>
</BODY>
</HTML>
Viewing the report with the activeX viewer works fine. The difference is that it uses WebReportBroker9 and WebReportSource9. If I try to use that code in my print page, the page loads but the printer dialog never shows.
I am using Crystal Reports 9 on my web server with IIS 5 on Windows 2000.
Any help would be appreciated.
Thanks
<HTML>
<HEAD>
<TITLE>Please Select a Printer</TITLE>
</HEAD>
<BODY BGCOLOR=C6C6C6>
<OBJECT ID="CRViewer"
CLASSID="CLSID:2DEF4530-8C
WIDTH=1% HEIGHT=1%
CODEBASE="/crystalreportvi
<PARAM NAME="EnableRefreshButton"
<PARAM NAME="EnableGroupTree" VALUE=0>
<PARAM NAME="DisplayGroupTree" VALUE=0>
<PARAM NAME="EnablePrintButton" VALUE=1>
<PARAM NAME="EnableExportButton" VALUE=0>
<PARAM NAME="EnableDrillDown" VALUE=0>
<PARAM NAME="EnableSearchControl"
<PARAM NAME="EnableAnimationContr
<PARAM NAME="EnableZoomControl" VALUE=0>
</OBJECT>
<SCRIPT LANGUAGE="VBScript">
<!--
dim timer
dim printerTimer
dim pageOne
PageOne = True
Sub window_onLoad()
Page_Initialize()
End Sub
Sub Page_Initialize
Dim webBroker
Set webBroker = CreateObject("WebReportBro
if ScriptEngineMajorVersion < 2 then
window.alert "IE 3.02 users on NT4 need to get the latest version of VBScript or install IE 4.01 SP1. IE 3.02 users on Win95 need DCOM95 and latest version of VBScript, or install IE 4.01 SP1. These files are available at Microsoft's web site."
CRViewer.ReportName = Location.Href
else
Dim webSource
Set webSource = CreateObject("WebReportSou
webSource.ReportSource = webBroker
webSource.URL = "rptserver.asp"
webSource.PromptOnRefresh = True
CRViewer.ReportSource = webSource
end if
CRViewer.ViewReport
End Sub
Sub CRViewer_DownloadFinished(
if downloadType = 1 and PageOne then
PageOne = False
timer = window.settimeout("OnMyTim
end if
end sub
Sub OnMyTimeOut()
if not CRViewer.IsBusy then
window.ClearTimeout(timer)
'window.alert "My timeout"'
CRViewer.PrintReport
printerTimer = window.SetTimeOut("OnPrint
end if
end sub
Sub OnPrinterTimeOut()
if not CRViewer.IsBusy then
window.ClearTimeOut(printe
' window.History.Back'
end if
end sub
-->
</SCRIPT>
</BODY>
</HTML>
ASKER
I saw that article. It applies to VB not VBScript, but if you try to use the code as they provide it the code will fail. There is no ReportWebBroker object or method available. Same thing for ReportWebSource. The code I have works on some computers but not others. I think the problem may be in configuration but I do not know anything for certain. The PCs that I am testing on all have the same version of the activex dll installed.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
VBscript is one of the languages that you can use with ASP. If you have examples in ASP I would like to see them.
We purchased Crystal Reports 9 Developer Edition.
We purchased Crystal Reports 9 Developer Edition.
ASKER
I figured it out. Ultimately my problem was two things:
1. Set webBroker = CreateObject("WebReportBro ker.WebRep ortBroker" ) and
Set webSource = CreateObject("WebReportSou rce.WebRep ortSource" )
Needed to be changed to
Set webBroker = CreateObject("WebReportBro ker9.WebRe portBroker ") and
Set webSource = CreateObject("WebReportSou rce9.WebRe portSource ")
2. The above code was being loaded into a frameset. So while the reference to webSource.URL = "rptserver.asp"
was fine for the viewer for the frameset it needed to reference the directory the pages were being called from. (webSource.URL = "reports/rptserver.asp")
The reason that it worked on some computers was that those computers had at one time had an earlier version of Crystal Reports installed. I still don't know how the location of rptserver.asp was resolved on those computers.
1. Set webBroker = CreateObject("WebReportBro
Set webSource = CreateObject("WebReportSou
Needed to be changed to
Set webBroker = CreateObject("WebReportBro
Set webSource = CreateObject("WebReportSou
2. The above code was being loaded into a frameset. So while the reference to webSource.URL = "rptserver.asp"
was fine for the viewer for the frameset it needed to reference the directory the pages were being called from. (webSource.URL = "reports/rptserver.asp")
The reason that it worked on some computers was that those computers had at one time had an earlier version of Crystal Reports installed. I still don't know how the location of rptserver.asp was resolved on those computers.
Glad you found it.
mlmcc
mlmcc
http://support.crystaldecisions.com/library/kbase/articles/c2014078.asp
mlmcc