Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ms-word

vba

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.

like image 648
Geoffrey Avatar asked Jul 21 '09 17:07

Geoffrey


2 Answers

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?

like image 125
Todd Main Avatar answered Nov 15 '22 07:11

Todd Main


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.

like image 22
Tom Winter Avatar answered Nov 15 '22 07:11

Tom Winter