Word 2003 event DocumentBeforeSave : how to know if really saved?

F

Frenchy

Hi all,

I'm still developing an add-in for Word2003 using VS2003 extensibility
project (C#).

Here's what I'd like to do; I need to write something in the custom
properties of a Word document if the user saved It.

So I used the event DocumentBeforeSave, It works perfect when the user saves
the document.

But if the user clicks on "save as" then cancel, the treatment is done
(because it's beforesave and not after). I'd like to know if there's a way to
know if the user really saved the document?

Thanks
 
F

Frenchy

Me again...

I found this half solution:

Cancel the save then display the FileSaveAsDialog and see if the user
clicked cancel.
Here's the code:
______________________
private void Application_DocumentBeforeSave(Word.Document Doc, ref bool
SaveAsUI, ref bool Cancel)
{
Cancel = true;
Word.Dialog dlgsaveas =
this.appWord.Dialogs[Word.WdWordDialog.wdDialogFileSaveAs];
object timeout = 0;
int i = dlgsaveas.Show(ref timeout);

if(i!=0)
{
//do something
}
}
______________________
I said It's a half solution because if the user already saved the document,
he shouldn't have to see the save as dialog box.

So I'm looking for a property which could tell me if the document has been
saved or not. The property "Saved" only tells if the document...is saved ;)
if there's been a modification since last save in fact.

I'm close to the solution maybe too close to see it :(

thanks
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?RnJlbmNoeQ==?=,
I said It's a half solution because if the user already saved the document,
he shouldn't have to see the save as dialog box.

So I'm looking for a property which could tell me if the document has been
saved or not. The property "Saved" only tells if the document...is saved ;)
if there's been a modification since last save in fact.
Hard to say without understanding how you're providing the Save and Save As
commands. Are you substituting your own command bar buttons for Word's
buttons? Providing your own, separate buttons?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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