JohnGalt

I've been able to hook into the Beforesave event on a word document and that's fine as far as it goes. However, I need to be able to process the file AFTER the file save completed (Loading it into a database)

Does anyone have any suggestions on how to hook into some event (that I'm obviously missing) or some other approach to know that the file has completed saving successfully so that I can process it

Thanks!



Re: Visual Studio Tools for Office Interop with Word - Notification AFTER document Saved

Cindy Meister

There is no event. But you should be able to "Cancel" Word's automatic behavior, send the Save command yourself, then continue processing. Save can be made synchronous by disabling the BackgroundSave option so your code won't continue until Word has finished.






Re: Visual Studio Tools for Office Interop with Word - Notification AFTER document Saved

JohnGalt

So that would mean that I would have to remove the save button, add my own and then save synchroniously

I was hoping to make it completely transparent to the user if at all possible without any installation of anything in their Word.





Re: Visual Studio Tools for Office Interop with Word - Notification AFTER document Saved

Cindy Meister

No, no. Use the BeforeSave event, as you've already figured out. That has a parameter that lets you set whether to Cancel Word's default behavior. Set that to "True" at the beginning, then you can handle the Save as part of the event.






Re: Visual Studio Tools for Office Interop with Word - Notification AFTER document Saved

JohnGalt

Thank you! I had a brain fart obviously Smile This will work great!




Re: Visual Studio Tools for Office Interop with Word - Notification AFTER document Saved

Cindy Meister

Nah, you're just too close to the problem :-) That's why communities are such a great thing - nothing like sitting back with a cup of [your favorite] to have a chat with some other folks who will give you a different perspective.

Ah, one thing to watch out for, because it's going to bite you and there's not a lot you can do about it: Word does have an "automatic save" behavior, and there's no way to detect whether the event is being fired by the user or by the automatic process.






Re: Visual Studio Tools for Office Interop with Word - Notification AFTER document Saved

JohnGalt

*Sitting back with Iced Tea in hand*

Argh... the event system for the office apps around this really need to be extended to support much better and more fine grained control. (i.e. why it's being saved, etc. and after save and after close events)

I'll live though Smile





Re: Visual Studio Tools for Office Interop with Word - Notification AFTER document Saved

JohnGalt

One more problem:

If the user clicks he close on the document the Close event is firing BEFORE the Save even though word is sitting there prompting for the save.

It doesn't make sense that a document can be closed before it's saved or at least prompted to save, but I need to figure out a way around it because here's the scenario that I have to be able to handle:

1. Save Document out to database

2. Open Word with that document

3. Save Document back to database

4. When document is closed, remove the file that word was using for the document.

I obviously can't delete the file after the save incase the save was just a save and not a close.

I can't delete it on the close, because if they close expecting the prompt, then the file will be deleted before the save occurs. (all because of a non-sensical event order!)

Is there a way around this so that I can know on close that there are not changese pending If there aren't, then I can delete it.

And then I would also need to know on save that the save is happening because the document was being closed.

Any ideas/





Re: Visual Studio Tools for Office Interop with Word - Notification AFTER document Saved

Cindy Meister

The document has a Saved property. If that's true, there are changes pending.

There's a BeforeClose event that's set up similar to BeforeSave you should be able to use. If that's called, set a class-level variable and check that in BeforeSave.






Re: Visual Studio Tools for Office Interop with Word - Notification AFTER document Saved

JohnGalt

Ok, I've got it working by intercepting and using my own save prompt dialog because otherwise it's a mess in the case of a no save but not cancel the close....

now I'm trying to do the same thing for Powerpoint...

The problem is that I can't find a BeforePresentationClose event for it so I can't intercept it and block the close from happening.

Any ideas





Re: Visual Studio Tools for Office Interop with Word - Notification AFTER document Saved

Cindy Meister

<sigh>The danger in answering an off-topic question that seems short and simple, and sort of related to the forum, is that it often snowballs... In the strictest sense, interop isn't supported in this forum, just the VSTO technology. You'll find a list of resources for interop questions in the Please Read First message at the top of the forum, including a link for Powerpoint. The PowerPoint specialists there should be able to help you further.

Good luck with your project :-)






Re: Visual Studio Tools for Office Interop with Word - Notification AFTER document Saved

JohnGalt

Thank you, and sorry for being off topic. I obviously didn't read that post and I couldn't find any thing else doing a search on MSDN for it.




Re: Visual Studio Tools for Office Interop with Word - Notification AFTER document Saved

M.Anwahi

Good afternoon,

I have the same requirement. Can you help me with that

I have to develop a .NET application that should read a word 2003 document from the database. The application should allow the user to edit the document. Once the user saves the document, it should be saved on the database.

I've tried to search on the web but I didn't succeed to find a solution. I appreciate if you guys can help me with design, frameworks, and same codes.

Regards,