Tuesday, March 22, 2011 12:24 PM
our .NET 3.5 application uses Office PIAs to create Word 2007 documents. The application uses e.g. the DocumentBeforeSave event to know when the user wants to save the document (it then writes the document into our database).
However, if the user has Auto Recovery enabled, our users get a message in Word saying something like "~WRDxxxxx.asd is postponed". ASD is the auto recovery data. The file name of the document then changes to the asd file. The document's name in the DocumentBeforeSave event is then named like the auto save file as well. The document's full name property is set to the full path and file name of the asd file. We do not get the event triggered twice (once for the asd file, once for the doc file) so simply checking on the file name and not doing anything if it ends with "asd" is not helpful. The document collection of the application object contains just the document with the asd file name as well.
Has anyone an idea how to convince Word to throw the DocumentBeforeSave event twice (once for the .asd file and once for the .doc/.docx file), or not throw the event for the auto recovery save at all, or how to retrieve the original document object?
- Moved by Paul Zhou Wednesday, March 23, 2011 5:36 AM not supported (From:.NET Base Class Library)
Wednesday, March 23, 2011 5:35 AM
I’m moving your thread to Word Development Forum.
There are experts in this forum so that you may get more useful information.
Have a nice day!
Paul Zhou [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Wednesday, March 23, 2011 5:26 PM
It looks you cancel BeforeDocumentClose. I'd recommend checking if the event was generated by the user action first. To do this, you can intercept all Ribbon controls which generate leads to generation of this event and set a flag in the event handlers; if the flag is not set in BeforeDocumentClose, then the event is caused by Word itself and you don't need to cancel it.
Do I understand you correctly?
Regards from Belarus (GMT + 2),
Add-in Express Team Leader
- Marked As Answer by Bruce SongModerator Friday, April 08, 2011 12:14 PM