Web Hosting Talk







View Full Version : Disabling Save function in a web browser


Davey Gale
02-24-2005, 06:12 AM
Hi there

We have developed a quote calculator for somebody in Microsoft Excel. It's very simplistic. (it is protected so changes cant be made - apart from drop down menus). The guy we're doing it for wants the Save feature to be disabled so when excel is closed it doesnt bring up the save option. Therefore each time the file is opened the drop downs are in their original state.

We put a macro in that stops the package from asking it to save. It is:

Private Sub Workbook_BeforeClose(Cancel As Boolean )
Application.DisplayAlerts = False
ThisWorkbook.Saved = True
Application.DisplayAlerts = False
End Sub

However this macro doesnt work online because the file is opened within a web browser - and not from within Excel itself. Does anyone know how i can mirror this same fuctionality through the web, and not just if the file was being ran through the excel package??

I've tried to work out how to have the file open within Excel itself and not embeded in a web browser - but to no avail. See thread: http://www.webhostingtalk.com/showthread.php?s=&threadid=378148

I hope this makes sense? Thanks.

Burhan
02-24-2005, 06:21 AM
Afaik, there is no way to do this in the web browser. The only way I can think of is that you force the download of the excel file and then the user will have to open it in Excel.

Davey Gale
02-24-2005, 06:27 AM
only way I can think of is that you force the download of the excel file and then the user will have to open it in Excel.

Hi, i thought that was the case, bit of a pain. Do you know how this is achieved? I point a link to the file on my server and when clicked it automatically opens within the browser. I'd love to be able to force a download choice - but i'm sure if its possible.

Rich2k
02-24-2005, 07:07 AM
You can do this by passing it through a PHP (or equivalent) script adding the Content-Disposition: attachment; header. This forces a download box. However IE5.5 (for those people who still use it) has HUGE bugs with this, no other browser seems to though.

Davey Gale
02-24-2005, 07:16 AM
Hey Rich2K, thanks for the info. I've heard of that header but dont know how to relate it to my file. I've experimented, i can get a download box to open but it opens up a new blank file and not the 1 i already have on the server.

Rich2k
02-24-2005, 09:52 AM
Try this in PHP


$theFile = '/path/to/file.xls';

header("Cache-Control: "); // leave blank to avoid IE errors
header("Pragma: "); // leave blank to avoid IE errors
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=\"Excel.xls\"");
header("Content-Length: " . filesize($theFile));

readfile($theFile);


A few notes, send blank cache headers especially over SSL as IE has a few bugs here.

Always send a content-length, can confuse some browsers when downloading from a script file.