Vba code to automatically update fields

B

Brad Zenner

Kind of new to the VBA thing, and I have a word form that has a calculated
field in it, and was wondering if there's vba code that would automatically
update that field or all fields in a document?

Any advise is greatly appreciated.
Thanks
Brad Zenner
 
G

Greg

Brad,

Several ways to update fields.

Select it and press F9
CTRL+a (selects all) and press F9
If you have your print options set up to update fields at print, then
you can toggle to and from Print Preview.

If it is just fields in the maintext story of the document you can run
the following macro:

Sub NoName()
ActiveDocument.Fields.Update
End Sub

If you have fields in other text stories you can use:

Sub UpdateAllFiled()
Dim oStory As Range
For Each oStory In ActiveDocument.StoryRanges
Do
oStory.Fields.Update
Set oStory = oStory.NextStoryRange
Loop until oStory is nothing
Next
End Sub

None of these methods are automatic. If you want the results to be
completely automatic you will have to perform your calculation using a
protected online form.
 

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