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 ...
-
18th March 2010, 02:10 PM #1 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
-
-
IDG Tech News
-
18th March 2010, 02:43 PM #2
-
-
18th March 2010, 03:16 PM #3 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 03:23 PM.
-
-
18th March 2010, 07:12 PM #4 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....
-
-
18th March 2010, 07:33 PM #5 
Originally Posted by
RichB
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.
-
-
19th March 2010, 10:14 AM #6 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 10:18 AM.
-
-
19th March 2010, 07:22 PM #7 
Originally Posted by
JoshJohnson
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:
Similar Threads
-
By theaman in forum Windows Server 2000/2003
Replies: 6
Last Post: 11th June 2009, 01:21 PM
-
By tomscaper in forum Scripts
Replies: 8
Last Post: 9th January 2008, 01:36 PM
-
By Kyle in forum General Chat
Replies: 5
Last Post: 9th November 2007, 12:43 PM
-
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
-
Forum Rules