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
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?
The essence of the update is:
application.customdocument
application.customdocument
...
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