View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson
 
Posts: n/a
Default Macro to Start an Application

Shell doesn't wait for anything. It simply starts the program
and VBA code execution move to the next line of code. If it takes
some time to fully open your application, you could use
Application.Wait to pause Excel, giving the program enough time
to fully start up.

Shell "your_program.exe"
Application.Wait Now + TimeSerial(0, 0, 15) 'wait 15 seconds
' more code

The code above will start "your_program.exe" then wait for 15
seconds, giving your_program.exe time to fully get itself
together, then continue on with VBA code. Change the 15 to the
number of seconds you feel is appropriate.


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




"Joe Teixeira" wrote in
message
...
That has worked great for Notepad and Calculator, but when I
tried to use it
to open an estimating application called Costworks, Costworks
only opened
"halfway". I closed Costworks and tried to open it directly
from it's
shortcut and it opened just fine. I tried increasing the
numeric value at
the end of the Run Shell line to 2 (no luck) and then to 3 (no
luck). I
thought that the Run Shell command wasn't giving the
application enough time
to open and by changing those values it would give the
application more time
to open. I have a support agreement with the estimating
application's
publisher but this is out of the agreement's scope.

"Paul B" wrote:

Joe, something like this, to run notepad

Sub Run_Notepad()
Run Shell("C:\WINDOWS\NOTEPAD.EXE", 1)
End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can
benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Joe Teixeira" wrote
in message
...
How do I write a macro to start another application?