Launching file in excel not internet explorer

  • Thread starter Thread starter virtualstorm
  • Start date Start date
V

virtualstorm

Help! I am trying to add a excel file onto an intranet file serve
however it always launchs the excel file in Internet Explorer. I
there anyway to force the file to open in Excel using VBA on a on ope
macro
 
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:pointer;" 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.
 
I had a similar problem. No one answered me, while I was searching KB and
discussion.

Finally here is the simple sol by Dave Peterson - Thank you Dave
_________________Dave's reply to somebody in the past _________
My fix is to not open excel files in MSIE.

How to Configure Internet Explorer to Open Office
Documents in the Appropriate Office Program Instead of in Internet Explorer
http://support.microsoft.com/?scid=162059

I'm betting that your macro gets confused with statements that refer to the
application. If you open in MSIE, the application is MSIE--not excel.

So something like:
application.screenupdating = false

might not even apply to MSIE.

(And menu items will be nicer if you open in excel.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top