Results 1 to 10 of 10
  1. #1
    5 Star Lounger Lou Sander's Avatar
    Join Date
    Jun 2002
    Location
    Pittsburgh, PA
    Posts
    855
    Thanks
    140
    Thanked 10 Times in 9 Posts

    Launch a Program From Excel (2003)

    I want to launch foo.exe by clicking a link on one of my workbooks.

    Can I do it, and if so, how?
    Lou Sander
    Pittsburgh, Pennsylvania
    USA

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Launch a Program From Excel (2003)

    You can hyperlink to an executable file like any other, but you will get security warnings when you try to launch it.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Launch a Program From Excel (2003)

    You can prevent the hyperlink warning from appearing by following the steps in this article. It deals with adjusting the registry, so be careful!

    See: http://support.microsoft.com/?kbid=829072
    Regards,
    Rudi

  4. #4
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Launch a Program From Excel (2003)

    A quick test (with Excel 2002) shows you can call a batch file from a macro:

    <code>Sub OpenWord()
    Shell("C:OpenWord.bat")
    End Sub</code>

    where OpenWord.bat consists of

    <code>"C:Program FilesMicrosoft OfficeOffice10winword.exe"</code>

    which doesn't appear to invoke any security warnings...

  5. #5
    5 Star Lounger Lou Sander's Avatar
    Join Date
    Jun 2002
    Location
    Pittsburgh, PA
    Posts
    855
    Thanks
    140
    Thanked 10 Times in 9 Posts

    Re: Launch a Program From Excel (2003)

    I've thought about it further, and actually what I want to open is a specific document, which Windows knows to open with foo.exe. I haven't tried it yet, but I think it might be easier, or might not have all the warnings.

    I think my link might be c:Foo Filesfoodocument.foo

    Am I on the right track?
    Lou Sander
    Pittsburgh, Pennsylvania
    USA

  6. #6
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Launch a Program From Excel (2003)

    <P ID="edit" class=small>(Edited by Rudi on 20-Jan-08 18:48. Query something after testing...)</P>This is a very interesting approach. This could be very useful!

    Leif, is there any reason why you have the Shell command run a batch file of stead of just running the path to Word directly in the Shell Command?
    Regards,
    Rudi

  7. #7
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Launch a Program From Excel (2003)

    Its a choice you will need to make.

    Either insert a hyperlink into Excel and point it to the document. This approach will cause a hyperlink warning to appear, which you could get rid of with the link I provided. Frankly, I would take Leif's approach that will not activate a warning (and avoid you having to tamper with the registry)

    Of stead of the hyperlink, use Leif's sample macro with a batch file you will need to create or copy this code into a VB module and run it from Tools | Macro | Macros.

    Sub RunFoo()
    Shell("C:Foo Filesfoodocument.foo") 'replace the path with the exact location of your document
    End Sub
    Regards,
    Rudi

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Launch a Program From Excel (2003)

    Shell only works with executables, not with documents. Your call to Shell will fail. One could use ShellExecute instead - see for example <post:=254,697>post 254,697</post:>.

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Launch a Program From Excel (2003)

    You could use

    ActiveWorkbook.FollowHyperlink "c:Foo Filesfoodocument.foo"

    or ShellExecute - see <post:=254,697>post 254,697</post:>.

  10. #10
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Launch a Program From Excel (2003)

    Sorry and tx for that correction.
    Regards,
    Rudi

Posting Permissions

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