How to run macro to shut down my PC?

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
 
E

EricG

Okay, ignore that. I just tried it and it does nothing. Probably a security
issue.

Sorry.
 
E

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
'***************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top