Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA to ShutDown PC

Could someone point me at some VBA to shut down a local PC
after a certain time. I'm okay with the Application.OnTime
method. And I've found the C code for the "ExitWindowsEx"
function but I'm afraid it's beyond me to convert to VBA.

All help welcome - Thanks - Phil


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default VBA to ShutDown PC


Phil, the VBA for the C code you found.. :)


'In general section
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindowsEx Lib "user32" _
(ByVal uFlags As Long, ByVal dwReserved As Long) As Long

Private Sub ShutDown()
Dim ret&
If MsgBox("Press Cancel to PREVENT Shutdown!", _
vbOKCancel + vbCritical + vbApplicationModal) = vbCancel Then End
'reboot the computer
'ret = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
'shutdown
ret = ExitWindowsEx(EWX_FORCE Or EWX_SHUTDOWN, 0)
End Sub


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Phil Greenwood" wrote:

Could someone point me at some VBA to shut down a local PC
after a certain time. I'm okay with the Application.OnTime
method. And I've found the C code for the "ExitWindowsEx"
function but I'm afraid it's beyond me to convert to VBA.

All help welcome - Thanks - Phil




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel.exe has generated errors and will be shutdown by windows jcook Excel Discussion (Misc queries) 0 April 22nd 08 02:20 PM
Timed shutdown of spreadsheet Steve Excel Discussion (Misc queries) 13 August 31st 07 02:18 PM
excel shutdown MRR Excel Discussion (Misc queries) 0 July 20th 06 01:58 PM
UPS Shutdown script clayton Excel Discussion (Misc queries) 2 December 13th 05 02:53 AM
Problems On Shutdown with Excel/VBA App Tim Sheppard Excel Programming 3 September 4th 03 08:19 AM


All times are GMT +1. The time now is 02:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"