ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA shell command - issues... (https://www.excelbanter.com/excel-programming/358903-vba-shell-command-issues.html)

JWM6[_2_]

VBA shell command - issues...
 

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,


--
JWM6
------------------------------------------------------------------------
JWM6's Profile: http://www.excelforum.com/member.php...o&userid=33413
View this thread: http://www.excelforum.com/showthread...hreadid=532972


Chip Pearson

VBA shell command - issues...
 
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



"JWM6" wrote
in message
...

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,


--
JWM6
------------------------------------------------------------------------
JWM6's Profile:
http://www.excelforum.com/member.php...o&userid=33413
View this thread:
http://www.excelforum.com/showthread...hreadid=532972




Dick Kusleika[_4_]

VBA shell command - issues...
 
JWM6

This works

Sub OpenIE()

Dim ieApp As Object

Set ieApp = CreateObject("InternetExplorer.Application")

ieApp.Visible = True

Set ieApp = Nothing

End Sub

--
Dick Kusleika
MS MVP - Excel
www.dailydoseofexcel.com

JWM6 wrote:
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,




JWM6[_3_]

VBA shell command - issues...
 

Thanks for the replies, will give it a shot..

--
JWM
-----------------------------------------------------------------------
JWM6's Profile: http://www.excelforum.com/member.php...fo&userid=3341
View this thread: http://www.excelforum.com/showthread.php?threadid=53297


JWM6[_4_]

VBA shell command - issues...
 

Works great - thanks!


--
JWM6
------------------------------------------------------------------------
JWM6's Profile: http://www.excelforum.com/member.php...o&userid=33413
View this thread: http://www.excelforum.com/showthread...hreadid=532972


JWM6[_11_]

VBA shell command - issues...
 

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,


--
JWM6
------------------------------------------------------------------------
JWM6's Profile: http://www.excelforum.com/member.php...o&userid=33413
View this thread: http://www.excelforum.com/showthread...hreadid=532972


Dick Kusleika[_4_]

VBA shell command - issues...
 
JWM6 wrote:
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

--
Dick Kusleika
MS MVP - Excel
www.dailydoseofexcel.com



JWM6[_12_]

VBA shell command - issues...
 

Thanks - I may give that a shot.


--
JWM6
------------------------------------------------------------------------
JWM6's Profile: http://www.excelforum.com/member.php...o&userid=33413
View this thread: http://www.excelforum.com/showthread...hreadid=532972



All times are GMT +1. The time now is 01:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com