We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


updating fields in word using vb

avi666 asked
Medium Priority
Last Modified: 2012-05-06
hi experts.
took me a while to understand how to update fields in word document. found out  "ActiveDocument.Fields.Update" command but I had a field in the header that was not updated with this command

so I found the "ActiveDocument.Sections(1).Headers(1).Range.Fields.Update" and was happy but once again, I had a field inside a shape that wasn't updated by both commands.

so I wonder, what are all the options to update a CustomDocumentProperty in a document, no matter where its location? what collections should I check? (Sections? StoryRanges? Shapes?)

I'm lost.
Watch Question

Top Expert 2012
To be certain, you have to process each range in each story.
Private Sub UpdateAllFields()
Dim oRange As Range
Dim oRange2 As Range
' Go through all story ranges in the document, including shapes,
' headers & footers.
For Each oRange In ActiveDocument.StoryRanges
    Set oRange2 = oRange 'set oRange2 to first range in story
        Set oRange2 = oRange2.NextStoryRange
    Loop Until oRange2 Is Nothing
Next oRange
End Sub

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


easy. fast. working. thank you.

(though I wish I knew more about Word architecture and how to get to fields directly and not through all-around loops)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.