ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Responding to system shutdown (https://www.excelbanter.com/excel-programming/399117-responding-system-shutdown.html)

sr216viper

Responding to system shutdown
 
Is there an event that fires in Excel when the shutdown.exe -f is used
outside Excel to reboot the system?

I have an Excel application running and I would like the opportunity to save
the workbook before the system shuts down.

JLGWhiz

Responding to system shutdown
 
Unless you have a very old version of Windows/Office/Excel it should
automatically save your work in the event of system failure. It will give
you an option on restart for which file you want to save under the original
file name. I always check the data in both versions before I decide, just to
be sure.

"sr216viper" wrote:

Is there an event that fires in Excel when the shutdown.exe -f is used
outside Excel to reboot the system?

I have an Excel application running and I would like the opportunity to save
the workbook before the system shuts down.


sr216viper

Responding to system shutdown
 


"JLGWhiz" wrote:

Unless you have a very old version of Windows/Office/Excel it should
automatically save your work in the event of system failure. It will give
you an option on restart for which file you want to save under the original
file name. I always check the data in both versions before I decide, just to
be sure.

"sr216viper" wrote:

Is there an event that fires in Excel when the shutdown.exe -f is used
outside Excel to reboot the system?

I have an Excel application running and I would like the opportunity to save
the workbook before the system shuts down.


We are using Excel to gather data from some solar systems. So its not
something that a user is working with interactive. So I was looking for an
event that will fire when shutdown.exe -f is used to reboot the system. That
way I can put code in the event to save the current set of data.

Chip Pearson

Responding to system shutdown
 
I think the only way would be to create a UserForm to load on startup and
then examine the CloseMode in QueryClose to see if the application is being
shut down by Windows.

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
' 2 = Windows is shutting down
' 3 = Task Manager is killing the process
If (CloseMode = 2) Or (CloseMode = 3) Then
' your shutdown code
End If
End Sub

Note that the UserForm need not be visible. You can just Load it without
Showing it. E.g.,

Sub Workbook_Open()
Load frmMyForm
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"sr216viper" wrote in message
...


"JLGWhiz" wrote:

Unless you have a very old version of Windows/Office/Excel it should
automatically save your work in the event of system failure. It will
give
you an option on restart for which file you want to save under the
original
file name. I always check the data in both versions before I decide,
just to
be sure.

"sr216viper" wrote:

Is there an event that fires in Excel when the shutdown.exe -f is used
outside Excel to reboot the system?

I have an Excel application running and I would like the opportunity to
save
the workbook before the system shuts down.


We are using Excel to gather data from some solar systems. So its not
something that a user is working with interactive. So I was looking for
an
event that will fire when shutdown.exe -f is used to reboot the system.
That
way I can put code in the event to save the current set of data.




All times are GMT +1. The time now is 09:08 PM.

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