stevenvh.net

Update fields in a Word document upon saving

Sub FileSave()
    ActiveDocument.Save
    Dim oStory As Range
    ActiveDocument.Fields.Update
    For Each oStory In ActiveDocument.StoryRanges
        oStory.Fields.Update
    Next oStory
    ActiveDocument.Save
End Sub


Sub FileSaveAs()
    Dim oStory As Range
    ActiveDocument.Fields.Update
    For Each oStory In ActiveDocument.StoryRanges
        oStory.Fields.Update
    Next oStory
    Dialogs(wdDialogFileSaveAs).Show
End Sub