+ Post New Thread
Results 1 to 7 of 7
Office Software Thread, running macros to open files in Technical; Hi, Im trying to create an excel spreadsheet (2007) where i can create a button an assign a macro to ...
  1. #1
    RichB's Avatar
    Join Date
    Oct 2008
    Location
    A Nice School
    Posts
    388
    Thank Post
    138
    Thanked 48 Times in 36 Posts
    Rep Power
    56

    running macros to open files

    Hi,

    Im trying to create an excel spreadsheet (2007) where i can create a button an assign a macro to it to open different software.

    For example click the button on the spreadsheet and it opens Sim.exe!

    Can this be done and if so how?

    Cheers not that good with excel

  2. #2
    RichB's Avatar
    Join Date
    Oct 2008
    Location
    A Nice School
    Posts
    388
    Thank Post
    138
    Thanked 48 Times in 36 Posts
    Rep Power
    56
    *bump*

  3. #3

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,432
    Thank Post
    1,432
    Thanked 1,160 Times in 794 Posts
    Rep Power
    705
    this should be quite simple, just add a button in to the spreadsheet, when it asks you which macro to run, select "New" then add the following code:
    Code:
    Shell "Path to the exe goes here"
    additionally, if you type a comma after the path to the exe, you'll get a self explanatory list of window modes to open the program in.

    Final tip: you can pass any file/folder to the Shell command and it will be opened in it's default viewer

    EDIT:
    don't forget that Sims is called pulsar.exe, though you might have to run simsload.exe to start it properly
    Last edited by LosOjos; 18th March 2010 at 02:23 PM.

  4. #4
    RichB's Avatar
    Join Date
    Oct 2008
    Location
    A Nice School
    Posts
    388
    Thank Post
    138
    Thanked 48 Times in 36 Posts
    Rep Power
    56
    Tryed to test this the code below:

    Sub Button1_Click()
    Shell "C:\Program Files\Microsoft Virtual PC.exe"
    End Sub


    get the error runtime error '53' file not found?

    any ideas have googled this but the file location is defo the one above?

    if a nut shell im trying to link all my tech tools to a excel spreadsheet to run the and organise them from there....

  5. #5
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,994
    Thank Post
    120
    Thanked 279 Times in 257 Posts
    Rep Power
    106
    Quote Originally Posted by RichB View Post
    Tryed to test this the code below:

    Sub Button1_Click()
    Shell "C:\Program Files\Microsoft Virtual PC.exe"
    End Sub


    get the error runtime error '53' file not found?

    any ideas have googled this but the file location is defo the one above?

    if a nut shell im trying to link all my tech tools to a excel spreadsheet to run the and organise them from there....
    I tried that code and it worked with a different path. Looks like you missed out a back slash to me as I doubt the exe is in the root of the Program Files folder.

    Shell "C:\Program Files\Microsoft Virtual PC.exe"
    Should it be

    Shell "C:\Program Files\Microsoft\Virtual PC.exe"
    I still doubt that is right though there still seems to be something missing.

  6. #6

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,432
    Thank Post
    1,432
    Thanked 1,160 Times in 794 Posts
    Rep Power
    705
    If you're certain that's the right path (although I agree with ChrisH, it seems quite unlikely the exe would be in the program files folder) then it might be that there are restrictions in place to stop VBA accessing the file system, try it with another file and see if it works, and also try using it to open a file in your home folder, I have had trouble in the past with VBA writing to the file system but not usually reading from it/calling a file from the shell command.

    If all else fails, try calling a file on a memory stick.

    Other than that I can't see why it wouldn't work, the code you used is fine
    Last edited by LosOjos; 19th March 2010 at 09:18 AM.

  7. #7

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,673
    Thank Post
    3,205
    Thanked 1,029 Times in 954 Posts
    Rep Power
    361
    Quote Originally Posted by JoshJohnson View Post
    If you're certain that's the right path (although I agree with ChrisH, it seems quite unlikely the exe would be in the program files folder) then it might be that there are restrictions in place to stop VBA accessing the file system, try it with another file and see if it works, and also try using it to open a file in your home folder, I have had trouble in the past with VBA writing to the file system but not usually reading from it/calling a file from the shell command.

    If all else fails, try calling a file on a memory stick.

    Other than that I can't see why it wouldn't work, the code you used is fine
    vba at least from experience does have access to the file system object ( I think its through the wmi vbs type add on ) so you could use the file system object to enumerate exe files but also as per above you would need to ensure that the program files directory is where the exe files you need to launch are in that directory whether in a sub directory or whatever.

    Once you know for sure it is the correct directory then you could do the above and use shell or make your own function in vba to launch exe files possibly using API calls in a module to shell execute ( assuming that api still exists ) it used to be shell execute in windows xp but if you are on windows 7 or vista etc you might run into problems with UAC and on windows 7 stricter permissions on the program files directory and other directories.

SHARE:
+ Post New Thread

Similar Threads

  1. prevent running .exe from ZIP files
    By theaman in forum Windows Server 2000/2003
    Replies: 6
    Last Post: 11th June 2009, 01:21 PM
  2. Kids Running VBS files
    By tomscaper in forum Scripts
    Replies: 8
    Last Post: 9th January 2008, 12:36 PM
  3. Running Open Office from a network Share?
    By Kyle in forum General Chat
    Replies: 5
    Last Post: 9th November 2007, 11:43 AM
  4. Running batch files in vista
    By Kained in forum Windows Vista
    Replies: 6
    Last Post: 4th September 2007, 02:25 PM

Thread Information

Users Browsing this Thread

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

Posting Permissions

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