Interpreting saveas exceptions

PhC
07-19-2004, 04:31 AM
Hello,

I want to start on an office automation project where I will basically let the user export data from my .NET application to an excel file.
I implemented the very helpful tutorial but just added a call to
oApp.GetSaveAsFilename
to let the user choose the filename.
Then when I call the
oWB.SaveAs
subroutine, I get a message if the user chose a filename that already existed, asking whether to overwrite the file yes/no/cancel
This is all perfect, except if the user does not choose yes, I get an Exception that I do not know how to handle (in particular the HRESULT code is the same whether the user chooses no or cancel :confused:
I suppose this is not a very complicated question but I searched the forums and msdn to no avail ...

Thank you for any help!!

herilane
07-19-2004, 06:13 AM
Welcome to the forum.

Would it not be easiest to check whether the file exists, before you call SaveAs? If it exists, you can show a MsgBox of your own where you can easily handle all possible user responses.

PhC
07-19-2004, 08:58 AM
Thank you for the quick suggestion :)

A little distance from the problem helps find the solution!

BTW for other people interested, if you do this you also need to erase yourself the file if the user wants to overwrite (else the call to saveas will present again the standard overwrite dialog).

Thanks again!

Philippe.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum