SteveGregory
Structural
- Jul 18, 2006
- 554
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!!!