i am currently encountering an issue where I'd like to put a link to a shared excel sheet in our intranet.
Unfortunately the normal href="http:..."
link automatically opens and saves it to the local machine instead of enabling the work on the shared sheet which is on the server itself.
I have read through here a bit and found solutions like : file://///SERVER/PATH/Excel.xls
but sadly that solution doesn't do anything.
If its relevant: my server version is Windows Server 2012
You can tell browser to open with Excel (if installed) by adding ms-excel:ofe|u| in front of your Excel file Url.
<a href="ms-excel:ofe|u|http:...xls">Open in Excel</a>
HTTP is a stateless protocol. What that means for you is that when your users download a file from the intranet via http, they are downloading a copy, rather than the original. Any changes they make will only appear in their copy, and then you end up with loads of copies of the same workbook with different, possibly overlapping changes. You don't want that!
And also ... how are your users even going to upload their changes?
You need to create a shared folder on your network and put the workbook there. You can then use the file:///SERVER/PATH/FILE.xls
format in your <a />
links on your intranet to direct your user to the actual file on the server.
I would recommend you start by creating a simple html doc on your desktop to get familiar with the file:///
path format.
Eg
<html>
<head />
<body>
<a href="file:///SERVER/PATH/FILE.xls">Click</a>
<body>
<html>
save that in notepad and rename the extension from .txt
to .html
.
You can also type file:///
paths straight into windows explorer's address bar which allow for testing paths without resorting to the html document mentioned above.
UNFORTUNATELY! It seems that the browsers default behavior is to always download a link rather than open it (even if it is a local resource), so if you actually want to open it then you must resort to changing your browser intranet permissions to allow JS to access local resources, which then allows you to use the technique below.
This article (http://www.codeproject.com/Articles/113678/How-to-execute-a-Local-File-using-HTML-Application) uses
<script type="text/javascript" language="javascript">
function RunFile() {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("c:/windows/system32/notepad.exe", 1, false);
}
</script>
to open notepad. You can use command line arguments with Excel.exe (https://support.office.com/en-za/article/Command-line-switches-for-Excel-321cf55a-ace4-40b3-9082-53bd4bc10725) to tell it what the file path is...
Excel.exe "C:\PATH\Excel.xls"
Use the below link if you are trying to open local file in excel.
<a href="ms-excel:ofe|u|file:///d:/folder/aaa.xlsx">Open in Excel</a>
Note: The file path should have forward slash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With