Home > Archive > ASP > May 2006 > Using ASP to open excel file
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Using ASP to open excel file
|
|
| jnb0012@unt.edu 2006-05-31, 6:56 pm |
| 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
%>
| |
| Bob Barrows [MVP] 2006-05-31, 6:56 pm |
| jnb0012@unt.edu wrote:
> 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.
>
> Set fs = Server.CreateObject("Scripting.FileSystemObject")
> If fs.FileExists("http://website/webreports/Misses/" & strfile) THEN
>
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.
| |
| Mike Brind 2006-05-31, 6:56 pm |
|
jnb0012@unt.edu wrote:
> 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
Get rid of http:// and use server.mappath to locate the physical path
of the files
--
Mike Brind
| |
| jnb0012@unt.edu 2006-05-31, 6:56 pm |
| I'm working now. Thank you both
|
|
|
|
|