Shell to a program based on OS Version
Shell to a program based on OS Version
(OP)
I am working on an Excel VBA macro that will keep a record of software usage.
After opening the spreadsheet, clicking a command button will stamp the current time and user name in the cell selected, move to the next cell down and launch a program. The path for the program being launched changes for a different Windows OS. I found an excel =INFO("osversion") function, but that returns "Windows (32-bit) NT 5.01" on my XP machine. I guess that works fine if it always works this way for Windows XP. What does this function return for Windows 7? Or perhaps you have a better way.
After the program is exited, the macro resumes and stamps the current time and user name in the new cell selected, moves to the next cell down and then saves the current spreadsheet and closes it.
Here is what I have so far:
Private Sub CommandButton1_Click()
Dim RetVal
ActiveCell = Now() & Environ("username")
ActiveWorkbook.Save
ActiveCell.Offset(1, 0).Select
'Win XP:RetVal = Shell("C:\Program Files\Bentley\Engineering\RAM Elements\RAMElements.exe", 1)
'Win 7:RetVal = Shell("C:\Program Files (x86)\Bentley\Engineering\RAM Elements\RAMElements.exe", 1)
RetVal = Shell("????... ????", 1)
ActiveCell = Now() & Environ("username")
ActiveCell.Offset(1, 0).Select
ActiveWorkbook.Close SaveChanges:=True
End Sub
Thanks for your help!!!
After opening the spreadsheet, clicking a command button will stamp the current time and user name in the cell selected, move to the next cell down and launch a program. The path for the program being launched changes for a different Windows OS. I found an excel =INFO("osversion") function, but that returns "Windows (32-bit) NT 5.01" on my XP machine. I guess that works fine if it always works this way for Windows XP. What does this function return for Windows 7? Or perhaps you have a better way.
After the program is exited, the macro resumes and stamps the current time and user name in the new cell selected, moves to the next cell down and then saves the current spreadsheet and closes it.
Here is what I have so far:
Private Sub CommandButton1_Click()
Dim RetVal
ActiveCell = Now() & Environ("username")
ActiveWorkbook.Save
ActiveCell.Offset(1, 0).Select
'Win XP:RetVal = Shell("C:\Program Files\Bentley\Engineering\RAM Elements\RAMElements.exe", 1)
'Win 7:RetVal = Shell("C:\Program Files (x86)\Bentley\Engineering\RAM Elements\RAMElements.exe", 1)
RetVal = Shell("????... ????", 1)
ActiveCell = Now() & Environ("username")
ActiveCell.Offset(1, 0).Select
ActiveWorkbook.Close SaveChanges:=True
End Sub
Thanks for your help!!!





RE: Shell to a program based on OS Version
Windows (32-bit) NT 6.01
but my Windows 8.1-64b returns
Windows (32-bit) NT 6.02
But I think that's because it's a 32-b version of Excel.
TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers
Of course I can. I can do anything. I can do absolutely anything. I'm an expert!
RE: Shell to a program based on OS Version
Next, I need to figure out how to get the macro to wait until I exit the program before executing the final steps of the macro (stamping the time, saving and closing).
RE: Shell to a program based on OS Version
http://msdn.microsoft.com/en-us/library/windows/de...
But that's assuming you can get the answer directly from the OS. This is what my command shell says for Windows 7, which is consistent with what Microsoft says:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
My Windows 8.1 command window shows Version 6.3.9600
TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers
Of course I can. I can do anything. I can do absolutely anything. I'm an expert!
RE: Shell to a program based on OS Version
RE: Shell to a program based on OS Version
See from link:
* For applications that have been manifested for Windows 8.1. Applications not manifested for 8.1 will return the Windows 8 OS version value (6.2). To manifest your applications for Windows 8.1 please refer to Targeting your application for Windows 8.1.
Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/
RE: Shell to a program based on OS Version
I am not sure if the local network server option is still available. Using Bentley's internet "server" allows us to use the programs at home at night or weekends. Bentley's structural programs have transitioned from allowing users to use a program if a license is available to "trust" licensing.
"Trust" means you can use as many licenses as you want. Bentley logs your usage in 1-hour increments. So if you own 1 license of "X" and Sam exits the program at 9:45. Then Cathy runs the program at 9:50. This counts as 2 license uses or one more than you own. So at the end of every 3 months, Bentley will check the logs and bill you for a 3-month "lease" for the extra licenses you used. If Cathy could have waited 10 minutes, then no extra charge!
We are trying to manage our usage to prevent extra charges.
RE: Shell to a program based on OS Version
http://answers.microsoft.com/en-us/office/forum/of...