using excel before windows shutdown

C

Chris Knievel

Hi,
i am trying to save some data in a excel spreadsheet, whenever the programm
shuts down.
Mostly this happens when a user is logging off or shuts the computer down.
im am using the
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
to save the data before the shutdown.
The problem is that i can't open excel. Windows is prompting that it can't
close my programm. And i am getting
some error messages like error code 800800005. Which is leading me to am MS
Website but that's not solving
my problem. Is there a chance to open excel somehow while windows is
shutting down, or do i have to save my data
in a different way?

thanks in advance
chris knievel
 
D

dermot

I would save your data quickly to text, and then next time app starts
up read this into excel?
 
G

GhostInAK

Hello dermot,

I would subclass the window procedure and trap the request to shutdown/restart
message. Return whatever value is required to abort the shutdown. Do your
dealio with excel, then initiate a second shutdown request prgrammatically.

-Boo
 
C

chris knievel

Hello,
thanks for your answers.
I am trying it with subclassing. And it's working so thanks a lot. But
is there a way to get the information wether the user is logging off or
shutting the computer down?
I know about WM_CLOSE, but i think it only tells me that the user is
shutting down, logging off or restarting. I would like to know what
exactly he is doing, so that i can continue his command after i've
saved my data in excel.

cheers
chris
 

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