close

How do I write a macro to start another application?

Joe, something like this, to run notepad

Sub Run_Notepad()
Run Shell(quot;C:\WINDOWS\NOTEPAD.EXEquot;, 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 amp; 2003

quot;Joe Teixeiraquot; gt; wrote in message
...
gt; How do I write a macro to start another application?
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
quot;halfwayquot;. 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.

quot;Paul Bquot; wrote:

gt; Joe, something like this, to run notepad
gt;
gt; Sub Run_Notepad()
gt; Run Shell(quot;C:\WINDOWS\NOTEPAD.EXEquot;, 1)
gt; End Sub
gt;
gt;
gt; --
gt; Paul B
gt; Always backup your data before trying something new
gt; Please post any response to the newsgroups so others can benefit from it
gt; Feedback on answers is always appreciated!
gt; Using Excel 2002 amp; 2003
gt;
gt; quot;Joe Teixeiraquot; gt; wrote in message
gt; ...
gt; gt; How do I write a macro to start another application?
gt;
gt;
gt;

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 quot;your_program.exequot;
Application.Wait Now TimeSerial(0, 0, 15) 'wait 15 seconds
' more code

The code above will start quot;your_program.exequot; 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

quot;Joe Teixeiraquot; gt; wrote in
message
...
gt; That has worked great for Notepad and Calculator, but when I
gt; tried to use it
gt; to open an estimating application called Costworks, Costworks
gt; only opened
gt; quot;halfwayquot;. I closed Costworks and tried to open it directly
gt; from it's
gt; shortcut and it opened just fine. I tried increasing the
gt; numeric value at
gt; the end of the Run Shell line to 2 (no luck) and then to 3 (no
gt; luck). I
gt; thought that the Run Shell command wasn't giving the
gt; application enough time
gt; to open and by changing those values it would give the
gt; application more time
gt; to open. I have a support agreement with the estimating
gt; application's
gt; publisher but this is out of the agreement's scope.
gt;
gt; quot;Paul Bquot; wrote:
gt;
gt;gt; Joe, something like this, to run notepad
gt;gt;
gt;gt; Sub Run_Notepad()
gt;gt; Run Shell(quot;C:\WINDOWS\NOTEPAD.EXEquot;, 1)
gt;gt; End Sub
gt;gt;
gt;gt;
gt;gt; --
gt;gt; Paul B
gt;gt; Always backup your data before trying something new
gt;gt; Please post any response to the newsgroups so others can
gt;gt; benefit from it
gt;gt; Feedback on answers is always appreciated!
gt;gt; Using Excel 2002 amp; 2003
gt;gt;
gt;gt; quot;Joe Teixeiraquot; gt; wrote
gt;gt; in message
gt;gt; ...
gt;gt; gt; How do I write a macro to start another application?
gt;gt;
gt;gt;
gt;gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()