Avatar of ged125
ged125
Flag for United States of America asked on

Word 2007 Macro to Update Document Properties

Can anyone out there provide some sample code that I could use to prompt and collect values for custom document properties and then do an update of all the fields throughout the doc?  I have a document that has several variables that I currently go in and manually enter, then I do a "CTRL-A" to select all the text and right click and select "Update Fields".  

Is there a way that I could run a macro, be prompted for all the values and then the document would generate itself?  

Thanks in advance.
Microsoft Word

Avatar of undefined
Last Comment
ged125

8/22/2022 - Mon
Chris Bottomley

Depending on what you require it could be a lot of work.  For example I have devised a form on which I can enter changed data for document properties I add to the document.  On pressing a button all fields are updated, issues creep up with non existing fields so I have various ini sections to address this.

The essence of the update is:
application.customdocumentproperties("propname").value = myform.mytextbox
application.customdocumentproperties("anotherpropname").value = myform.mynexttextbox
...

followed by
 a loop
for each story in activedocument.storyranges
   story.select
   story.fields.update
   selection.collapse direction:=wdcollapsestart
next

myform.hide
application.saved = false

Any help?

Chris
ged125

ASKER
would it be possible to get the complete code?
ged125

ASKER
application.customdocumentproperties isn't available for me.  Any idea why?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
Chris Bottomley

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ged125

ASKER
That's what I was looking for!  Thanks Chris!