Opening External File

edpudol
08-07-2004, 09:15 PM
How could I open an html file that will automatically open the default browser. I try to use the following code but I got error:

Shell "tempfile.htm",vbMaximizedFocus
Any suggestion?

huntercobrax
08-07-2004, 09:22 PM
You need to put the path of the file you are trying to open.

edpudol
08-07-2004, 09:34 PM
Thanks but I have done that but still won't work... :confused:

huntercobrax
08-07-2004, 09:41 PM
hm....You could try ShellExecute:


Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long


And what exactly does the error say?

edpudol
08-07-2004, 09:51 PM
if I use this code it works
Shell "C:\Program Files\Internet Explorer\iexplore.exe C:\Program Files\Microsoft Visual Studio\VB98\a.htm", vbMaximizedFocus

I get the error file not found if I use this one

Shell "C:\Program Files\Microsoft Visual Studio\VB98\a.htm", vbMaximizedFocus

I don't want to use the first code because some users don't want to use IE as a browser.

So other solution?

huntercobrax
08-07-2004, 10:26 PM
Ok i cant get he 'Shell' thing to wrork either but the API Function 'ShellExecute' works fine:


Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Form_Load()

ShellExecute Me.hwnd, vbNullString, "C:\Program Files\Microsoft Visual Studio\VB98\a.htm", vbNullString, "C:\", SW_SHOWNORMAL

End Sub

MikeJ
08-07-2004, 11:37 PM
Unfortunately, the ShellExecute method doesn't let you open it into a new
browser window if you use IE. I've created an example that uses Shell but
uses your default browser by getting the value from the registry and then
using the VB Shell function on that path.

http://www.xtremevbtalk.com/showthread.php?t=167624

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum