VBA shell command - issues...

J

JWM6

The VBA shell command is as follows:

programPath = "C:\Program Files\Internet Explorer\iexplore.exe" '
works
'programPath = "iexplore.exe" ' does not work
Shell programPath + " " + fileToLaunch, vbNormalFocus

but the drawback is that the invoked program (iexplore.exe, at least in
my case) needs to have the FULL PATH to where the program exists = the
"C:\Program Files\Internet Explorer" which may or may not work on
someone elses computer. This hardcoding will not work and is not
transportable.

Is there a trick to find where the executing program lives? or
launching it without the path?

Thanks,
 
C

Chip Pearson

Try

Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
MsgBox IE.FullName
IE.Quit
Set IE = Nothing


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



in message
news:[email protected]...
 
D

Dick Kusleika

JWM6

This works

Sub OpenIE()

Dim ieApp As Object

Set ieApp = CreateObject("InternetExplorer.Application")

ieApp.Visible = True

Set ieApp = Nothing

End Sub
 
D

Dick Kusleika

JWM6 said:
So I wanted to bat this idea around but I'll give some context...

I'm in Excel doing some stuff, then I use the VBA shell command to
launch IE and siaply stuff in the IE frame. What I'd like to happen
is I get control returned to my Excel app (underneath the IE shelled
window) after the IE window is closed.

Any way to keep the Excel app from coming to the front and things
continuing while the IE window is up? Then when the IE window is
dismissed, I can unblock and give control back to the Excel app...

Thanks,

JWM

I don't know if I particularly like this solution, but it's all I've got.
It checks to see if ieApp is visible every 10 seconds (change to suit) and
displays a message box when it's gone. I'm using early binding here (my
last post was late bound, I think) so you'll have to set a reference to
Microsoft Internet Controls or convert to late bound.

Public ieApp As InternetExplorer
Public Const dINTER As Double = 1.15740740740741E-04 '10 seconds

Sub WaitForIe()

Dim sUrl As String

Set ieApp = New InternetExplorer

ieApp.Visible = True
ieApp.Navigate "http://www.dailydoseofexcel.com"

Application.OnTime Now + dINTER, "CloseIE"

End Sub

Sub CloseIE()

Dim bVis As Boolean

bVis = False
On Error Resume Next
bVis = ieApp.Visible
On Error GoTo 0

If bVis Then
Application.OnTime Now + dINTER, "CloseIE"
Else
Set ieApp = Nothing
MsgBox "IE Closed"
End If

End Sub
 

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

Top