March 18th, 2003, 02:57 PM
Launching MS Word to open file from a hyperlink?
Wondering if this can be done. I have the path generated from asp variables. I have the following code:
<a href="file:<%=sPath & sYear & "\" & sFileName%>" TARGET="_blank">Open Generated File</a>
This will launch the file in an IE window. I was wondering if it would be possible to have the same link above but have word open the file instead of IE? Have something like a jscript function that does onclick...blah..blah. Is this possible? If so, any sample coding or where to get more information would be great
March 18th, 2003, 07:40 PM
If you link to a .doc file and the user's machine has a file association setup so that .doc files are opened with Word, whenever they click on the link it will open the file with word. You can put this in a new window using the target property as you have done in your example.
Just make sure the file that is linked to is a .doc
March 19th, 2003, 09:32 AM
tks for the reply. I tested out the file association and my machine already has .doc files associated with MS Word. I kept the target=_blank, should this be changed? As an alternative, in case anyone here wanted to know, I found some jscript code that does this for you. Here is the sample coding that I used to launch the link in MS Word:
and add the following jscript:
var myApp = new ActiveXObject("Word.Application");
if (myApp != null)
myApp.Visible = true;
Note: in order to link to UNC paths, make sure that strFile is using "/" in its path versus the conventional "\". For eg. use:
//computer/folder/file instead of \\computer\folder\file.