I have a problem that is a bit tricky.
I am trying to find a way to execute a program using an Excel spreadsheet.
We have several computers that all have different user names, and the issue is each of them have restrictions in place (business computers) that make it difficult to use some new software we have installed because if they are closed, the computers won't let us reopen them using the default shortcuts.
To make deployment of this sheet easy, I was wanting to see if I could use the Windows XP environment variables %HOMEPATH% or something similar as a part of the reference or link to the .exe we are using. Everything we install installs to either Local Settings or Application Data under the current user.
At the moment, I am able to make a hyperlink with a direct reference to the file, but that doesn't work on the other computers and I can't oversee setting up the other computers :P
Any ideas on how to make this work. I have pretty much counted on using VBA, but we have another catch: I can't run batch files on most of the machines, because again of the restrictions in place. If it can't be done that's ok, but I want to give it a shot![]()
It would suggest that you check with your department before doing anything.
You might be able to use a Shell command
Sub OpenNotePad() Dim RetVal RetVal = Shell("C:\WINDOWS\notepad.exe", 1) End Sub
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
I already checked with my boss and he was ok with it. So to modify the code to show what I am aiming for:
The issue is that since we are actually needing to go into the %HOMEPATH% of the computer because of the way it installs programs, this is limiting the options I'm afraid. This is a start though, and I will keep cracking at it. Not one for giving up.Sub OpenNotePad() Dim RetVal RetVal = Shell("&WINDIR%\notepad.exe", 1) End Sub
On a side note, if I try to wrap that subroutine into a button click directly, it expects an End Sub. If I route to it via GoTo either straight away or If, Then (Not needed I know but I was checking) it says not defined. I'm not sure why I would need to define an action that would really serve only to open the shell and execute essentially a temporary script.
When I try to run the code I posted above, it says file not found so I know it's not recognizing the Environment Variable which is what I need from it.
Last edited by hackersarchangel; 08-07-2010 at 05:23 AM. Reason: additional information
One possible solution is to make a batch file that will execute the program. The only real catch is finding a way to terminate the batch file window after it opens. I know the batch file should be able to access the folder based on that. I will do some testing tomorrow and see how easy it will be to deploy. Trying to make this as painless for the end user as possible :P.
If I could wrap it all into a button that would rock but I'm thinking Excel doesn't do environment variables so the batch file may be the easiest method from a programming stand point, also less bloated code wise and probably just as easy to deploy just so long I make so it's all in the same folder.
Have a look at Environ
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks