Get the Result of Excel Dialog, when closing excel?

G

Guest

Hi All

Is it possible to get the result of the Yes, No, Cancel Dialog that apers
when i close an excel. It is asking if i would like to save the excel
workbook.

I need an event that apears if someone clicks No, or Cancel. Is there a way
to get an event for these two actions? or something else i should do to know
if somebody clicked no or cancel?

my problem is, that i need to execute code after the
workbookbeforeSave-Event. In the taskbar the Excel.exe process is not
closing...if someone knows how i could solve that problem i would be very
happy. then the first problem wouldn't be a problem anymore and i do not have
to kill the Excel.exe process by myself...

using c#, vs .net, vb.net is also understood

thanks for your help
m. ahrens
 
J

Jim Cone

m,

Maybe this will help with the second problem...

http://support.microsoft.com/?kbid=317109
"When you automate a Microsoft Office application from
Microsoft Visual Basic .NET or Microsoft Visual C# .NET,
the Office application does not quit when you call the Quit method"

Regards,
Jim Cone
San Francisco, USA
 
G

Guest

thanks for your help! that was very helpfull!! Excel closes correctly now!

But i have another problem... still need to get to know if the user clicked
Yes,No,Cancel when he closes excel...what event do i have to use for that and
how can i see what he has clicked on?

thanks
m.ahrens
 
J

Jim Cone

m.ahrens,

You are asking a blind man what it look like...

In C#, do you have anything equivalent to "Typename".
If so, it could possibly tell you whether Excel is still open...
If TypeName(xlApp) = "Application" then Excel is still
open (cancel was clicked).

Also, you might be able to get the date last modified for the
applicable file and compare it to the value saved before
opening Excel to determine if Yes or No was clicked.

There are probably better ways to do both.

In Excel VBA, one can eliminate the offending message with...
"Application.DisplayAlerts = False"
or determine the "Saved" state of the workbook with...
If ActiveWorkbook.Saved = True then (Yes was clicked).

Regards,
Jim Cone
San Francisco, USA
 

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