Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Edit Excel from Link 1

Status
Not open for further replies.

jennuhw

MIS
Apr 18, 2001
426
US
I have a page where there is a link to an Excel document on the web server. The link and upload works fine. The problem lies when the user edits the document and tries to save it, it automatically wants to do a save as with My Documents being default. Is there a way to open the document in ASP without losing the filepath so the user can just hit save? Here is how the document is being opened:

Code:
<a href="files/<%=lors.fields("filepath")%>" target="_newwindow">View File</a>

This will normally be an Excel document, but it could be about anything. Thanks!
 
When the browser requests a file from a web server, the web server opens the file and responds with a copy of the file contents. So the user doesn't really have the file. The user has a copy of the file... Any edits are changes to the user's copy of the file... the server's copy remains intact.
 
jennuhw,
As Sheco said, you only receive a copy of the file. When it opens it opens on your PC from your temp files folder.

There is another way though.
This bit of code will open an Excel file from the specified location. This uses ActiveX so it will probably only work with IE browsers.
The client will receive an ActiveX warning unless there security settings are set low. The file will open client-side and the rights to the file will be based on that persons logon ID and permissions assigned to the folder the file resides in, not the IUSR_machinename account. So you will need to know that the people who need to edit these files have been setup with rights for that folder.

The file opens client-side but pointing to the server location so when they save it will by default be to the same file/location.

Code:
<script language="VBScript">
dim filesys
Set filesys = CreateObject("Excel.Application")
filesys.Visible = true
filesys.workbooks.open("\\mmdata1b1r1\csddata\Outlook mods.xls")
filesys.Close 
</script>

Now, this code works well when on an ASP page but with the VBScript tags. If you put it on an asp page with asp script tags you will get an activeX error. If you put it on a normal HTML page with VBScript tags it works but gives an error on the filesys.Close line. So just put it onto your ASP page.


Paranoid? ME?? WHO WANTS TO KNOW????
 
I a version of this yesterday, but it didn't work. My brain was fried. With a couple of changes, this is working great! Here is my code:

Code:
<script language="VBScript">
function startExcel(myfile)
	dim filesys
	Set filesys = CreateObject("Excel.Application")
	filesys.Visible = true
	filesys.workbooks.open("\\esp7\globalfiles\" & myfile)
	'filesys.Close 
end function
</script>

<td><input type="button" value="Open File" onclick="startExcel('<%=filename%>');"></td>

Now, I am going to make necessary changes to make it work with Word! Thanks!


[ponytails]
 
Isn't this client-side script rather than ASP script?

What I'm getting at with that question is... would it be possible to re-write it in JavaScript so it could run on other browsers?
 
Yes, in fact my original code is javascript
Code:
    strFile = "myfilepath\\myfilename.xls"
    var myApp = new ActiveXObject("Excel.Application");
    myApp.Visible = true;
    myApp.Workbooks.Open(strFile);
    myApp = nothing;

He was asking in the ASP forum though so I modified it a bit.

Paranoid? ME?? WHO WANTS TO KNOW????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top