+ Reply to Thread
Results 1 to 6 of 6

How to start an application from Excel VBA

  1. #1
    NoSpam@aol.com
    Guest

    How to start an application from Excel VBA

    I would like to start an application from Excel VBA and pass command line
    parameters to it. Once the app is started it should run completely
    independently from the instance of Excel that started it.

    Excel shouldn't wait on it to to anything (including terminate).

    Thanks.

  2. #2
    Chip Pearson
    Guest

    Re: How to start an application from Excel VBA

    See the Shell statement.


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


    <NoSpam@aol.com> wrote in message
    news:7i1b32htj314cn5ghlgmquiharuloasmj9@4ax.com...
    >I would like to start an application from Excel VBA and pass
    >command line
    > parameters to it. Once the app is started it should run
    > completely
    > independently from the instance of Excel that started it.
    >
    > Excel shouldn't wait on it to to anything (including
    > terminate).
    >
    > Thanks.




  3. #3
    NoSpam@aol.com
    Guest

    Re: How to start an application from Excel VBA

    Thanks, I haven't tried it yet but it looks like exactly what I needed. I
    tried "Spawn", "Execute", "Start" and several others, but I didn't think to
    look up "Shell".

    On Thu, 6 Apr 2006 17:15:48 -0500, "Chip Pearson" <chip@cpearson.com>
    wrote:

    >See the Shell statement.



  4. #4
    Forum Contributor
    Join Date
    04-12-2006
    Location
    Morgan Hill CA
    Posts
    107
    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. Is there a trick to find where the executing program lives? This hardcoding will not work and is not transportable.

    Thanks,

  5. #5
    Forum Contributor
    Join Date
    04-12-2006
    Location
    Morgan Hill CA
    Posts
    107

  6. #6
    Registered User
    Join Date
    07-07-2009
    Location
    Urloffen, Brazil
    MS-Off Ver
    Excel 2003
    Posts
    1

    Cool Re: How to start an application from Excel VBA

    I'm trying to get this shell function working but w/o the desired success:

    that's my code:

    Sub runSubMagic()
    programPath = "D:\Program Files\Video\SubMagic5-8\subMagic"
    fileToLaunch = "H:\VIDEO\MOVIES\movies 2010\movieTitle" & "\" & "movieTitle.en.srt"
    Shell programPath + " " + fileToLaunch, vbNormalFocus
    End Sub

    It starts the application but does not load the file "movieTitle.en.srt". I have tried this:
    programPath = """" & "D:\Program Files\Video\SubMagic5-8\subMagic" & """"
    fileToLaunch = """" & "H:\VIDEO\MOVIES\movies 2010\movieTitle" & """" & "\" & "movieTitle.en.srt"

    but it doesn't help either. Executing the code step by step also does not create an error whatsoever.

    Any idea what might be wrong?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1