Geoffrey
Geoffrey

Reputation: 5432

How do I check programmatically if any document properties of a MS Word 2007 document has changed?

For example, I want the Title fields in the body and the page headers of the document to be updated automatically whenever the Title field in the document properties panel is changed. I know how to update the fields, but I want to know the name of the event that will tell me when the document properties have changed.

Your help will be appreciated. Thanks.

I also asked it on the MSDN Forums.

Upvotes: 6

Views: 831

Answers (2)

Todd Main
Todd Main

Reputation: 29153

You can certainly check for these kinds of things in some of the events, such as DocumentBeforeClose or WindowSelectionChange, but this may be overkill. Instead, you could just use fields - they will update automatically. For example, go to Insert and then click on Quick Parts and then Field... Go to the Document Information section in the dropdown on the left and choose Title. Then, insert that and go back to the Home tab on the Ribbon and set its style to Title.

You also mention you also want page headers - are those properties you're setting in the Document Panel?

Upvotes: 1

Tom Winter
Tom Winter

Reputation: 1923

Word doesn't have any events like that. The best you might be able to do is use the selection change event, which will happen fairly often, but then you have to check all the propertiers of all the documents.

I think you're trying to do something that Word doesn't normally do. There are certain times when fields are updated and that's it. Teach you users how it works.

Upvotes: 1

Related Questions