Hi

I have a application whith three frames. In the third frame ("Results") I
want to display an excel-generated report (the report is generated through
VBA macros, which run when the template is opened (auto_open sub),
collecting the data from an SQL Server). Normaly, in Excel, the template
creates an instans of itself (resultning in an .xls-file). I want my
application to do the same, that is, I want the template (xlt) to create an
instans (xls), load the data into the xls-file and then display the
xls-report in the fram "results".

I'm quite new to VB-Script and I've only manged to come up with the
following code, in report.asp:

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Dim xlApp
Dim xlWb
Dim xlSheet

Set xlApp = CreateObject("Excel.Application")
Set xlWb = xlApp.Workbooks.Open("c:\data\report.xlt")
Set xlSheet = xlWb.Worksheets(1)

xlSheet.Name = "Report1"

xlApp.Visible = True

Set xls = Nothing
Set xlb = Nothing
Set xlapp = Nothing
</Script>

This doesn't work. I think I don't get any error messages, though, and the
CPU on the server is working for about 5 secs, so I think the report is
generared but not displayed on screen(?).

Excel 2000 is installed on the server.
Can anyone help me please?

Regards
PO

Re: Displaying xl-worksheets in IE by Joe

Joe
Mon Aug 16 04:55:30 CDT 2004

"PO" <po> wrote in message news:uY5N7o2gEHA.1344@TK2MSFTNGP11.phx.gbl...
> Hi
>
> I have a application whith three frames. In the third frame ("Results") I
> want to display an excel-generated report (the report is generated through
> VBA macros, which run when the template is opened (auto_open sub),
> collecting the data from an SQL Server). Normaly, in Excel, the template
> creates an instans of itself (resultning in an .xls-file). I want my
> application to do the same, that is, I want the template (xlt) to create
> an
> instans (xls), load the data into the xls-file and then display the
> xls-report in the fram "results".
>
> I'm quite new to VB-Script and I've only manged to come up with the
> following code, in report.asp:
>
> <SCRIPT LANGUAGE=VBScript RUNAT=Server>
> Dim xlApp
> Dim xlWb
> Dim xlSheet
>
> Set xlApp = CreateObject("Excel.Application")
> Set xlWb = xlApp.Workbooks.Open("c:\data\report.xlt")
> Set xlSheet = xlWb.Worksheets(1)
>
> xlSheet.Name = "Report1"
>
> xlApp.Visible = True
>
> Set xls = Nothing
> Set xlb = Nothing
> Set xlapp = Nothing
> </Script>
>
> This doesn't work. I think I don't get any error messages, though, and the
> CPU on the server is working for about 5 secs, so I think the report is
> generared but not displayed on screen(?).
>
> Excel 2000 is installed on the server.
> Can anyone help me please?
>
> Regards
> PO
>
The code you give is designed to run on the server so there is little point
in trying to make the application visible. You could save the resulting
document and use the path as a link to your workbook or send the data as a
binary stream to the browser with the correct mime-type.

There are two caveats, firstly all users of your web page would need an
Excel licence, secondly if any message box is displayed by Excel then your
server will crash. See this link:

http://support.microsoft.com/default.aspx?kbid=257757

You will also need to make sure that the auto macros run, they don't by
default when Excel is automated.

--

Joe (MVP)