473,441 Members | 1,897 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,441 software developers and data experts.

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("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
%>

May 31 '06 #1
3 7279
jn*****@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.
May 31 '06 #2

jn*****@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

May 31 '06 #3
I'm working now. Thank you both

May 31 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: David Gerstman | last post by:
I've written an application for reading information from a spreadsheet and allowing the user to add and update information in the spreadsheet. One spreadsheet I accessed in this fashion is now...
4
by: see_mun_lee | last post by:
I use asp to develop a web page to read an excel file containing Chinese Character then display it in the web page. Unfortunately, I cant display it!!! it will display (?????????). <META...
1
by: Sarah | last post by:
Hello. I am using Microsoft.Office.Interop.Excel in a C# .NET project. I want to open an Excel application with a specific file name. I am currently opening it with this code: ...
4
by: Chris | last post by:
Hi, everything works apart from the last line :-(( rng.Value2.ToString() An exception is thrown : "Old format or invalid type library" It gets compiled though (so he recognizes the property...
4
by: Jae | last post by:
I'm writing a web application that exports and imports excel files. The application gets a list of users and their info and displays it in a datagrid .The user then selects to save the file as a...
0
by: Rich Wallace | last post by:
Hello all, Looking for suggestions and tips if possible. I have an application running on a file server that utilizes the FileSystemWatcher to trap when any Excel files are saved by a user. I...
2
by: Jacob.Bruxer | last post by:
Hi everyone, I'm having trouble opening space delimited textfiles in Excel from Visual Basic.net. I'm able to control, open and modify Excel files from Visual Basic, so my Excel reference seems...
2
by: musa.biralo | last post by:
Hi, i want to read each row of specific column of musa.dbf using macro (VBA) in excel. my main gole is to copy the data of dbf file to excel file. I am new but want to do something..i tried and...
0
by: wankhusairi | last post by:
hallo sir .. i am still new on using vb and i have tried to load an excel using a visual basic interface.. but if i wanted to plot my excel data what should i do.. must i cahnge my program on loading...
1
by: Doogie | last post by:
Can anoyne tell me why this VBScript will create the file to Excel just fine, but the Excel file will not open up? I am saving it as a xlsx file instead of an xls one and I have the new version of...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.