Work Life Balance and Time Management
"All Work and No Play makes Jack a Dull Boy"
- Downloaded times
Easy to Implement New Ideas
Excel, combined with VBA, is a Simple and Powerful Application. Not only simple calculations, it can even take control over the system to a great extend. In this page, we will see how we can Lock or Shutdown a computer from an Excel. But, why do we need to learn such option. Let’s plug in this option for some good purpose. These days’ people spend lot of time with eyes stuck on the monitor and with mind roaming in virtual world. Let’s use this option to give them a break. With the code explained below, user can set a time limit (i.e., 1 Hr or 1 ½ Hrs) and give commands to the system to lock at this predefined time interval. Read: How to simplify Appointment updates to Outlook Calendar with Excel?How to Lock Windows System with Excel VBA?
To develop this App, we need two Modules:- Module1: To Lock the workstation
Open a command prompt and execute this command "rundll32.exe user32.dll, LockWorkStation" or we can use the LockWorkStation Windows API Function. This will lock the workstation. We are going to invoke this command from VBA.
Private Declare Function LockWorkStation Lib "user32.dll" () As Long
Sub Lock_Computer_Method_1()
'''''Call API to Lock Workstation. This Function does not have any Parameters
LockWorkStation
End Sub
Sub Lock_Computer_Method_2()
''''Create Object for executing rundll32 exe. Create an object for WScript.
Set WshShell = CreateObject("WScript.Shell")
''''Now pass the parameter to lock the workstation to rundll32 exe
WshShell.Run "rundll32.exe user32.dll,LockWorkStation"
End Sub
- Module2: A Timer to call module1 on a scheduled interval
Download Excel App
Note: Please read the limitation of this tool before using it.- Downloaded times