How to run macro to shut down my PC?

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

Does anyone have any suggestions on how to code macro to shut down my PC?
I have a list of code within macro to be run for 3 hours, I would like to
add coding at the end of this macro to shut down my PC.
Does anyone have any suggestions on how to do it?
Thanks in advance for any suggestions
Eric
 
Could anyone please tell how to add condition into macro?
I would like to add coding only run TurnOffPC only after 4 pm
Does anyone have any suggestions?
Thank everyone very much for any suggestions
Eric

Sub mycoding
....
....

TurnOffPC;
End Sub


'*******************SHUT DOWN*********************
Sub TurnOffXP()
'shutdown.exe will NOT work on Windows 95, 98, 98 SE and ME
ActiveWorkbook.Save
Application.DisplayAlerts = False
Application.Quit
'//shut down the computer
Shell "shutdown -s -t 02", vbHide
End Sub

Sub TurnOffPC()
Dim Action As Long
ActiveWorkbook.Save
Application.DisplayAlerts = False
'//shut down the computer
Action = ExitWindowsEx(EWX_SHUTDOWN, 0&)
Application.Quit
End Sub
'***************************************************
 
Back
Top