Can't launch Internet Explorer

A

Adrian D. Bailey

I have a VBmacro that writes some webpages.
I want the last line of the macro to launch a browser to display the first
of the pages.

I've tried this...
dummy = Shell("iexplore " & Environ("temp") & "\showpeople1.htm",
vbNormalFocus)
....but I get File Not Found.

Oddly, if I replace "iexplore" with "notepad" it works, with Notepad
launching and showing me the HTML code.

Ideally, I'd like to launch the user's default browser - whether that's IE,
or Firefox or whatever.

Any tips, please?
--
Adrian D.Bailey, Information and Systems Manager, Dept.Human Sciences
Loughborough University, Loughborough Leics, LE11 3TU, UK.
(e-mail address removed) Tel: 01509 223007 Fax: 01509 223940

Community Warden, Storer and Burleigh Areas. Out-of-hours Tel: 01509 563263
--
 
P

Peter T

Have a go with this to launch in deafult browser

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

Public Declare Function GetDesktopWindow Lib "user32" () As Long

Sub Test()
Dim hWndDesk As Long
Dim res&
Dim sFile$

sFile = Environ("temp") & "\" & "myFile.htm"
hWndDesk = GetDesktopWindow()

res = ShellExecute(hWndDesk, vbNullString, sFile, _
vbNullString, vbNullString, vbNormalFocus)

Debug.Print res
Select Case res
Case Is > 32
' should be up & running
Case 2
'file not found
Case Else
'some other error specific to res
End Select

End Sub

Might also need something along the lines of ShellAndWait, search google for
other error codes.

Regards,
Peter T
 

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

Similar Threads

Network Username 2
Find position of cursor in text box 2
Getting started 1
Rounded Rectangle 3
Problem with Network Latency 2
When to use With - End With? 3
What's this new sheet? 6
Speed this up for me, please 1

Top