Consulting

Results 1 to 5 of 5

Thread: Run .exe from VBA code

  1. #1
    VBAX Newbie
    Joined
    Jan 2007
    Posts
    3
    Location

    Run .exe from VBA code

    Hi ALL

    How to run .exe files from VBA code.

    Anand.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    retval = Shell("C:\Windows\Calc.Exe",1)
    [/vba]

  3. #3
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    If you do not want to use the Shell method, you can also use the FollowHyperlink method from any standard module (or UserForm for that)...

    [VBA]Sub TestRunFile()
    ActiveWorkbook.FollowHyperlink "C:\YourPath\YourFile.exe"
    End Sub[/VBA]

    HTH

  4. #4
    VBAX Contributor Ivan F Moala's Avatar
    Joined
    May 2004
    Location
    Auckland New Zealand
    Posts
    185
    Location
    Zack, the problem with that method is it generates a modal warning msg about hyperlinks being harmfull. I have always prefered Shell or RunDll (to over come this) unless it is a Doc of an Application in which case I would use Shell API to exercute / open in default application.
    Kind Regards,
    Ivan F Moala From the City of Sails

  5. #5
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    True Ivan, I forgot to mention the warning. Thanks.

Posting Permissions

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