views:

728

answers:

3

I have a intranet webpage that is used to hyperlink to various files on a file server.
The problem with the local-file linking is that Microsoft Excel files are opened in IE7 instead of Excel.
This results in the Excel files VBA code and other features from working correctly.

Is there a way using HTML/Javascript to force the file to be opened in Excel instead of IE7?

+6  A: 

its been a long time but I used to do something like this. This is server side code obviously, I know you specified javascript/html.

Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("content-disposition", "attachment;filename=test.xls");

EDIT

Here is a decent enough example though a little old http://aspalliance.com/259_Downloading_Files__Forcing_the_File_Download_Dialog

Gratzy
Wouldn't this work with only one file? There are 30+ files linked on the HTML page.
John M
They only open one file at a time correct?
Gratzy
That is correct - only one file at a time.
John M
Added a link to a full working sample, its an old post but a decent example.
Gratzy
+2  A: 

Or in PHP you would do this:

 //send headers that should force download
 header('Content-Type: application/vnd.ms-excel');
 header('Content-Disposition: attachment; filename="downloaded.pdf"');
 // and output the file:
 readfile('file.xls');
Pim Jager
Wouldn't this work with only one file?
John M
+2  A: 

Well, if you are feeling a bit naughty: http://support.microsoft.com/kb/162059

"""To configure Internet Explorer to open Office files in the appropriate Office program instead of in Internet Explorer, use one of the following methods. """

It won't really help for systems out of your control ... unless, of course you can convince them to run some privileged ActiveX/script, .reg file, or modify the settings as described (I do not really recommend any of these).

pst
Good suggested link but won't work on the terminal servers that most users are on - would need IS to configure as the default for all users.
John M