Solved

Using PrintReport over the web

Posted on 2003-12-02
6
2,512 Views
Last Modified: 2007-12-19
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.WebReportBroker'" 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-8CE6-41c9-84B6-A54536C90213"
      WIDTH=1% HEIGHT=1%
      CODEBASE="/crystalreportviewers/activeXViewer/activexviewer.cab#Version=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="EnableAnimationControl" 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("WebReportBroker.WebReportBroker")
      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("WebReportSource.WebReportSource")
            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("OnMyTimeOut",1000)
      end if
end sub

Sub OnMyTimeOut()      
      if not CRViewer.IsBusy then
            window.ClearTimeout(timer)
            'window.alert "My timeout"'
            CRViewer.PrintReport
            printerTimer = window.SetTimeOut("OnPrinterTimeOut", 1000)

      end if
end sub

Sub OnPrinterTimeOut()
      if not CRViewer.IsBusy then
            window.ClearTimeOut(printerTimer)
'            window.History.Back'
      end if
end sub
-->
</SCRIPT>
</BODY>
</HTML>
0
Comment
Question by:u8semaj
  • 3
  • 3
6 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 9859965
0
 

Author Comment

by:u8semaj
ID: 9860881
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.
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 9863748
I don't know since I don't use VBScript.  Is that closer to ASP?  If so I can provide examples from ASP.

Which edition of CR9 did you buy?

mlmcc
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:u8semaj
ID: 9866377
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.
0
 

Author Comment

by:u8semaj
ID: 9870514
I figured it out.  Ultimately my problem was two things:

1.  Set webBroker = CreateObject("WebReportBroker.WebReportBroker") and
     Set webSource = CreateObject("WebReportSource.WebReportSource")
     Needed to be changed to
     Set webBroker = CreateObject("WebReportBroker9.WebReportBroker") and
     Set webSource = CreateObject("WebReportSource9.WebReportSource")

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.


0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9870980
Glad you found it.

mlmcc
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question