Groups | Blog | Home
all groups > inetserver asp general > may 2006 >

inetserver asp general : Using ASP to open excel file


jnb0012 NO[at]SPAM unt.edu
5/31/2006 11:20:11 AM
Can anyone help with this? Here is the code I am using. The problem
is, where it checks if a file exists, it always goes to else. Even if
the file is there, it won't open the file, goes straight to else part
of statement.

<%
If Session("strLogID") = "" Then
Response.Redirect("http://website/pages/login.asp")

Else
strfile = Request.Form("month") & Request.Form("day") & " Misses" &
".xls"

Set fs = Server.CreateObject("Scripting.FileSystemObject")
If fs.FileExists("http://website/webreports/Misses/" & strfile) THEN

Response.Redirect("http://website/webreports/Misses/" & strfile)

Else
Response.Redirect("http://website/pages/missedreport.asp")

End If
End If
%>
Mike Brind
5/31/2006 11:45:02 AM

[quoted text, click to view]

Get rid of http:// and use server.mappath to locate the physical path
of the files

--
Mike Brind
jnb0012 NO[at]SPAM unt.edu
5/31/2006 12:15:47 PM
I'm working now. Thank you both
Bob Barrows [MVP]
5/31/2006 2:41:39 PM
[quoted text, click to view]


[quoted text, click to view]

A FileSystemObject requires a filesystem path, not a url. Use
Server.MapPath to generate the filesystme path:

url="http://website/webreports/Misses/"
strPathAndFile = Server.MapPath(url & strfile)
'for debugging:
Response.Write "strPathAndFile contains '" & strPathAndFile & _
"'<BR>"
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

AddThis Social Bookmark Button