Save event is fired too early in Excel Save As command.

Add-in Express™ Support Service
That's what is more important than anything else

Save event is fired too early in Excel Save As command.
 
Yuri Astrakhan


Guest


The Excel's WorkbookBeforeSave event is fired after hitting Ctrl+S fine, but if the user is editing a new Excel file and does a Save As..., the event is fired before the dialog box is shown up.

Is there a way to find out what file name was given to the file after it gets saved? What happens if the user hits Cancel?

Thanks,

--Yuri
Posted 14 May, 2006 23:40:07 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Yuri.

You can use the Word.Document.FullName property to learn about the name given to the file by the user. If the user hits Cancel, this property is not changed.
Posted 15 May, 2006 09:25:10 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Yuri, I was mistaken a little.
I meant the Excel._Workbook.FullName property.
Posted 15 May, 2006 11:26:59 Top
Yuri Astrakhan


Guest


Sergey,

The problem is not in finding out the filename, but in detecting when it changes. I guess i can have some sort of a timer that waits for a while and then checks that value, but if the value is not changed, it might mean the user is still in the SaveAs dialog. I was hoping for an easy way to detect when the file has already been saved (or right before that), and know the file name.

Thanks for the reply!
--Yuri
Posted 15 May, 2006 13:02:59 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Yuri.

I tried to simulate the WorkbookAfterSave event but with no luck.
Now I see only one solution. You can try to disable the standard action of the SaveAs button and develop your own 'Save As' dialog.
Posted 16 May, 2006 09:10:13 Top
Brad Smith




Posts: 49
Joined: 2005-11-22
I've had to deal with a similar limitation with Word. Indeed I read somewhere that completely overriding the default SaveAs and implementing your own dialog is the only "solution".

Does Excel have a WindowDeactivate/WindowActivate event pair? While it's unbelievably hacky, Through judicious use of flags you might be able to trap an "Activate" after the SaveAs dialog has gone away and look for your properties of interest then. Yeah, I know, yucky.

Brad.
Posted 16 May, 2006 17:33:51 Top
Andrei Smolin


Add-in Express team


Posts: 18791
Joined: 2006-05-11
Brad,

Though Excel 2003 does have these events, they don't fire for me after closing the SaveAs dialog whether I save the book or click Cancel.

Andrei
Posted 17 May, 2006 03:37:45 Top
Brad Smith




Posts: 49
Joined: 2005-11-22
Bummer. That's going to make life difficult. MS sure didn't make it easy for add-in authors to do stuff. :-(
Posted 17 May, 2006 16:14:48 Top
Yuri Astrakhan


Guest


Thanks everyone!

I think i will have to go the "weird" route - a timer that checks the filename every so often, and if it changes without any save events - i will know the document got saved. The obvious difficulty is handling various other events - the workbook is closed, different workbook becomes active, etc.

--Yuri
Posted 18 May, 2006 14:43:33 Top