UPS Shutdown script

  • Thread starter Thread starter clayton
  • Start date Start date
C

clayton

I just got a UPS for our computer that has the ability to run an
program/batch file/etc that can be executed from the command line whe
the power goes out.

I want to somehow make a batch file or something that will be able t
execute the below code when the power goes out.
This is the same code that is normally executed by the user at the en
of the night by pressing a button.



Code
-------------------

Sub SHUTDOWN_WIN()
If Worksheets.count > 1 Then
unhideall
Call split_worksheet_to_workbook
End If
Application.DisplayAlerts = False
ActiveWorkbook.Save
Call Shell("c:\windows\system32\Shutdown.exe -s -t 0", 1)
ActiveWorkbook.Close

Application.DisplayAlerts = True
End Su
-------------------


This code must somehow be executed from within the workbook itself a
it calls other functions. I don't know if this is possible or not bu
it sure would be handy..
 
I was thinking about what I could do to make this work. What I came up
with is this. If the UPS executes a batch file that creates a file
named shutdown.txt then I could have my already open excel file check
for that file every 15 minutes or so and if it exists to execute my
shutdown code which would also delete the shutdown.txt file.

Any other suggestions would greatly be appreciated. :)
 
Back
Top