Click to See Complete Forum and Search --> : Opening Excel in ASP


kbrown2974
04-09-2004, 09:15 AM
I am attempting to open a spreadsheet thru ASP. I think it opens it because it errors out on a different line than the open. I would like it to pop-up in the window so I can actually see it. The code I have so far is below:

<%
Dim fso
Dim act
Dim xlsit
Dim xlsbook
thepath = "n:\outbound\mortcamp\reports\mortout.xls"
set fso = createobject("Excel.Application")
fso.visible = true
fso.UserControl = true
set act = fso.Workbooks.Open("n:\outbound\mortcamp\reports\mortout.xls")

set xlsbook = act.workbooks.add

act.close true
fso.quit

set fso = nothing
set act = nothing
set xlsit = nothing
%>

buntine
04-09-2004, 09:27 AM
Mate, why did you post this in the 'general' forum?? Thats a great way to make people think your stupid...

Why have you defined a variable named 'thePath' and then not used it? The reason for creating the variable is to use it.

act.close true

That line will cause an error.

Regards.

kbrown2974
04-09-2004, 09:42 AM
The thepath variable was used in a previous version..didnt take it out. Any ideas on how far off I am from this working? When I open the page as it is now, I dont get an error...just a blank page

buntine
04-09-2004, 09:50 AM
Your using an outdated method. Actually, the use of excel in an ASP page is a bad idea.

Look at this example: http://www.asp101.com/samples/viewasp.asp?file=xl%5Fdata%2Easp

buntine
04-09-2004, 09:51 AM
By the way, you cant just have the contents of a excel fiel displayed in the page, you have to format it and display it using HTML.

kbrown2974
04-09-2004, 11:14 AM
That works but is there a way to preserve the Excel formatting?

buntine
04-09-2004, 11:59 AM
I dont understand... IE cant retain the formatting of an excel document.