tags:

views:

7000

answers:

9

OK, I know this is a total newbie question, but I can't find any solutions with Google that work for me.

I want a list of hyperlinks on a basic html page, which point to files on our corporate intranet.

When a user clicks the link, I want the file to open. They are excel spreadsheets, and this is an intranet environment, so I can count on everyone having Excel installed.

I've tried two things:

1 - The obvious and simple thing:

<a href="file://server/directory/file.xlsx">Click me!</a>

2 - A VBScript option that I found in a google search:

<HTML>
<HEAD>
<SCRIPT LANGUAGE=VBScript>
Dim objExcel

Sub Btn1_onclick()
    call OpenWorkbook("\\server\directory\file.xlsx")
End Sub

Sub OpenWorkbook(strLocation)

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = true
objExcel.Workbooks.Open strLocation
objExcel.UserControl = true
End Sub

</SCRIPT>
<TITLE>Launch Excel</Title>
</HEAD>
<BODY>
<INPUT TYPE=BUTTON NAME=Btn1 VALUE="Open Excel File">
</BODY>
</HTML>

I know this is a very basic question, but I would appreciate any help I can get.

Edit: Any suggestions that work in both IE and Firefox?

+1  A: 

<a href="file://server/directory/file.xlsx" target="_blank"> if I remember correctly.

diciu
Works in IE, but not firefox. Going to try suggestion by typemismatch.
JosephStyons
A: 

Your first idea used to be the way but I've also noticed issues doing this using Firefox, try a straight http:// to the file - href='http://server/directory/file.xlsx'

typemismatch
Doesn't work in IE or Firefox, for me.
JosephStyons
A: 

A simple link to the file is the obvious solution here. You just have to make shure that the link is valid and that it really points to a file ...

Jan Hancic
I agree. So how do I implement such a simple link in HTML?
JosephStyons
+1  A: 

If the file share is not open to everybody you will need to serve it up in the background from the file system via the web server.

You can use something like this example.

Turnkey
In this case, the authentication is already being done before they get to this web page. Anyone who gets here should have access to these files, and to the directory in which they are stored. I really want to keep this simple.
JosephStyons
+1  A: 

You may need an extra "/"

Click me!

Sam Reynolds
Tried w/o success.
JosephStyons
But a total of five "/"s worked! You were close :)
JosephStyons
+1  A: 

If your web server is IIS, you need to make sure that the new Office 2007 (I see the xlsx suffix) mime types are added to the list of mime types in IIS, otherwise it will refuse to serve the unknown file type.

Here's one link to tell you how:

Configuring IIS 6 for Office 2007

Ken Ray
+3  A: 

Try formatting the link like this (looks hellish, but it works in Firefox 3 under Vista for me) :

<a href="file://///SERVER/directory/file.ext">file.ext</a>
David Heggie
Awesome. I knew it had to be something simple. Works for me in Ffx and IE. I'm using XP, for the record.
JosephStyons
I think you may actually have one too many slashes. You need 2 for the file:// protocol and 2 for the server name //SERVER/.
Orion Adrian
Works for me with the five slashes, not with the four that you'd expect to need. Don't ask me why ...
David Heggie
Firefox needs five slashes indeed.
Gleb
A: 

You're going to have to rely on each individual's machine having the correct file associations. If you try and open the application from JavaScript/VBScript in a web page, the spawned application is either going to itself be sandboxed (meaning decreased permissions) or there are going to be lots of security prompts.

My suggestion is to look to SharePoint server for this one. This is something that we know they do and you can edit in place, but the question becomes how they manage to pull that off. My guess is direct integration with Office. Either way, this isn't something that the Internet is designed to do, because I'm assuming you want them to edit the original document and not simply create their own copy (which is what the default behavior of file:// would be.

So depending on you options, it might be possible to create a client side application that gets installed on all your client machines and then responds to a particular file handler that says go open this application on the file server. Then it wouldn't really matter who was doing it since all browsers would simply hand off the request to you. You would have to create your own handler like fileserver://.

Orion Adrian
A: 

Is it possible to do the same thing usin Open Office Calc? Thanks

Geber12