I don't know how to check where a document opens, but I use the code below
in a vbs file referred to in my web pages to start any document in their
rightful parent application:
Below the code is how to refer to the vbs file from your web pages and how
to pass the call to open a document or anything else actually.
This code will only work in IE:
'******************************
' code in vbsrun.vbs file
'******************************
Dim gobjFileSys, gstrFolder
Dim ShellObject, pstrTempFolder
Sub LaunchIt(FilePathName)
If not Cbool(ReportFileStatus(FilePathName)) then
Description = Chr(13) & "The " & FilePathName _
& Chr(13) & "could not be found!"
MsgBox "There has been a problem!" _
& Chr(13) & "Description: " & Chr(13) & Description
_
& Chr(13) & Chr(13) & "Please use the Dialog Box to
locate it.", 64
Err.Clear
FindFiles
Exit sub
End if
' On Error Resume Next
Dim objShell
'MsgBox FilePathName
Set objShell=CreateObject("Wscript.Shell")
objShell.Run Chr(34) & FilePathName & Chr(34)
If Err.Number <> 0 Then
If Err.number=424 then
MsgBox "Your Security Settings in your Intranet
zone" _
& Chr(13) & "do not allow the use of
unsigned ActiveX" _
& Chr(13) & Chr(13) & "Please notify the
Administrator.", 16
Exit Sub
ElseIf Err.number=-2147024894 then
If not ReportFileStatus(FilePathName) then
Description = Chr(13) & FilePathName _
& Chr(13) & "could not be found!"
MsgBox "There has been an error: " &
Err.Number _
& Chr(13) & "Description: " &
Description _
& Chr(13) & Chr(13) & "Please notify
the Administrator.", 48
Err.Clear
FindFiles
Exit sub
End if
Else
If Err.Description = "" Then Err.Description =
Chr(13) & FilePathName _
& Chr(13) & "could not be found!"
MsgBox "There has been an error: " &
Err.Number _
& Chr(13) & "Description: " &
Err.Description, 48
End If
End If
Set objShell = nothing
End Sub
Function ReportFileStatus(filespec)
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
ReportFileStatus = fso.FileExists(filespec)
End Function
Sub FindFiles()
Dim objFileSys
Set objFileSys = CreateObject("Scripting.FileSystemObject")
Dim objDialog
Const cintHideReadOnly = &H4&
Const cintOverwritepstrPrompt = &H2&
Const cintPathMustExist = &H800&
Const cintForWriting = 2
Set objDialog = CreateObject("MSComDlg.CommonDialog")
With objDialog
.InitDir = "F:\"
.Flags = cintHideReadOnly + cintOverwritepstrPrompt + _
cintPathMustExist
.Filter = "All Files (*.*)|*.*"
.FilterIndex = 0
.MaxFileSize = 260
.CancelError = true
.ShowOpen
End With
LaunchIt objDialog.FileName
End Sub
'******************************
' code ends here
'******************************
'******************************.
' in the web page, in the header section
'******************************
' note the lice below assume that bthe vbs file is located in a folder
named 'include'
'
<SCRIPT SRC="include/vbsrun.vbs" type="text/vbscript"><!-- --></SCRIPT>
'******************************
' passing a document name
' to be launched in the
' proper namespace
'******************************
<a style="cursor

ointer;" onClick="LaunchIt('file:///C:\\Documents and
Settings\\Philippe\\My Documents\\MS Office\\MS Excel\\Organisers\\Internet
Organisers\\26_07_04_New_Organiser\\0_26_07_04_New_Organiser.xls');">New
Organiser v0, 26<sup>th</sup> July 2004, by Moi</a>
where:
'C:\\Documents and Settings\\Philippe\\My Documents\\MS Office\\MS
Excel\\Organisers\\Internet
Organisers\\26_07_04_New_Organiser\\0_26_07_04_New_Organiser.xls'
is the most important since it is the document name. The rest , STYLE sets
the mouse cursor to change into a pointing finger as one would expect from a
link.