Reputation: 83
I have some VBA code which takes hours to run. After completion of the code, I want the windows 7 (64 Bit Professional) to go to SLEEP.
What VBA code can I use at the end to achieve this?
Upvotes: 0
Views: 717
Reputation: 674
Correct me if I'm wrong, but I'm not aware of a way to do this natively in vba. Usually for these sort of things I'll search the internet for a way to do it in the command prompt, then have my vba run a command line script.
Sure enough, here is an explanation of how you can shut down / sleep via command line.
And you'll find many examples online of running command line scripts from vba which you can use to execute these commands. At it's most basic, something like this:
shell "notepad.exe"
Upvotes: 1