ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   UPS Shutdown script (https://www.excelbanter.com/excel-discussion-misc-queries/60013-ups-shutdown-script.html)

clayton

UPS Shutdown script
 

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

I want to somehow make a batch file or something that will be able to
execute the below code when the power goes out.
This is the same code that is normally executed by the user at the end
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 Sub
--------------------


This code must somehow be executed from within the workbook itself as
it calls other functions. I don't know if this is possible or not but
it sure would be handy...


--
clayton
------------------------------------------------------------------------
clayton's Profile: http://www.excelforum.com/member.php...fo&userid=4563
View this thread: http://www.excelforum.com/showthread...hreadid=492816


clayton

UPS Shutdown script
 

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. :)


--
clayton
------------------------------------------------------------------------
clayton's Profile: http://www.excelforum.com/member.php...fo&userid=4563
View this thread: http://www.excelforum.com/showthread...hreadid=492816


clayton

UPS Shutdown script
 

OK, this is my last post until someone replies I promise! LOL

I did the above and all is working! Except... If someone left the form
with the cursor blinking in a cell. Like if you were to double click on
a cell it lets you type into that cell. Well, if it is like that then
the script will not execute until you leave that cell.
I have tried having the script change to a different sheet with no
luck. I've even tried sendkeys but that doesn't work either...

Any suggestions for this problem? I should probably start a new
thread...


--
clayton
------------------------------------------------------------------------
clayton's Profile: http://www.excelforum.com/member.php...fo&userid=4563
View this thread: http://www.excelforum.com/showthread...hreadid=492816



All times are GMT +1. The time now is 07:05 PM.

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