Using ASP to open excel file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jnb0012@unt.edu

    Using ASP to open excel file

    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("strLog ID") = "" Then
    Response.Redire ct("http://website/pages/login.asp")

    Else
    strfile = Request.Form("m onth") & Request.Form("d ay") & " Misses" &
    ".xls"

    Set fs = Server.CreateOb ject("Scripting .FileSystemObje ct")
    If fs.FileExists(" http://website/webreports/Misses/" & strfile) THEN

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

    Else
    Response.Redire ct("http://website/pages/missedreport.as p")

    End If
    End If
    %>

  • Bob Barrows [MVP]

    #2
    Re: Using ASP to open excel file

    jnb0012@unt.edu wrote:[color=blue]
    > 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.
    >[/color]

    [color=blue]
    > Set fs = Server.CreateOb ject("Scripting .FileSystemObje ct")
    > If fs.FileExists(" http://website/webreports/Misses/" & strfile) THEN
    >[/color]

    A FileSystemObjec t 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 "strPathAnd File 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.


    Comment

    • Mike Brind

      #3
      Re: Using ASP to open excel file


      jnb0012@unt.edu wrote:[color=blue]
      > 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("strLog ID") = "" Then
      > Response.Redire ct("http://website/pages/login.asp")
      >
      > Else
      > strfile = Request.Form("m onth") & Request.Form("d ay") & " Misses" &
      > ".xls"
      >
      > Set fs = Server.CreateOb ject("Scripting .FileSystemObje ct")
      > If fs.FileExists(" http://website/webreports/Misses/" & strfile) THEN[/color]

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

      --
      Mike Brind

      Comment

      • jnb0012@unt.edu

        #4
        Re: Using ASP to open excel file

        I'm working now. Thank you both

        Comment

        Working...