ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hibernate using Excel macro (https://www.excelbanter.com/excel-programming/284965-hibernate-using-excel-macro.html)

Rod Armour

Hibernate using Excel macro
 
Hi group,

I'm trying to tell a Win2k machine to boot from hibernate
automatically in the morning, run two programs unattended during the
day, one of them Excel XP, and then shut down in the afternoon. The
problem is that Win2k automatically goes back into hibernatation if it
has no tasks to perform, and unfortunately it does not accept my timed
Excel macros as cause for remaining on, so the computer goes back into
hibernation after just a few minutes. After attempting various
solutions, I have concluded that the answer is to employ a macro to
turn "hibernation" off in Win2k after the computer boots (resumes in
the morning), and then turn it back on before shut down in the
afternoon. I have been trying to access the "Hibernate" tab in Power
Option Properies (Control Panel) from an Excel macro, but that's the
problem. I can get to Power Option Properties using "SendKeys," but
once there, none of the "SendKey" commands act as expected and I can
find no combination that will highlight the Hibernate tab in order to
turn hibernatation off (and back on). For example, SendKeys "^{TAB}"
does NOT act like Ctrl+Tab on the keyboard. Does anyone know how to
send Ctrl+Tab using sendkeys, or call the Power Options Hibernate tab
from an Excel VB macro in order to turn hibernation on and off? If
not, might someone know how to turn hibernatation on and off with
Excel VB by another method?

Part of the code I've been using, but the SendKeys command "^(TAB)"
does not change tabs in the Power Options dialogue box.

Set WshShell = CreateObject("WScript.Shell")
'Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "^{ESC}", True 'presses the Start button
Application.Wait Now + TimeValue("00:00:01")
WshShell.SendKeys "{DOWN}", True 'highlights a link to Power Options
Application.Wait Now + TimeValue("00:00:01")
WshShell.SendKeys "{ENTER}", True 'opens Power Options
Application.Wait Now + TimeValue("00:00:02")
WshShell.SendKeys "^{TAB}", True 'problem is here, this does NOT
switch tabs

Thanks for the help!


All times are GMT +1. The time now is 10:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com