FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

MS Word 2002: How to update fields on save? VB Macro?

 


cambridge
as in the subject.

MS Word does not updates fields automatically. User have to manually update a field, or choose print preview (or print), to see updated fields.

But I need solution which is transparent to user: on every doc save fields have to be updated and shown. Field I use are: RevNum, SaveDate, LastSavedBy. Unfortunately, RevNum is not updated after save.. The solution would be a macro, I suppose.

Can anybody help modify one of the samples I've found (I don't know Visual BAsic..)? I need macro which updates fields on save.

1. (taken from http://gregmaxey.mvps.org/Word_Fields.htm)

'
Code:
Sub UpdateFields()
Dim pRange As Word.Range
For Each pRange In ActiveDocument.StoryRanges
  Do
    pRange.Fields.Update
    Set pRange = pRange.NextStoryRange
  Loop Until pRange Is Nothing
Next
End Sub


2. from http://ask.support.microsoft.com/kb/291474/
Code:
Sub UpdateAllFields()

   Dim aStory As Range
   Dim aField As Field

   For Each aStory In ActiveDocument.StoryRanges
      For Each aField In aStory.Fields
         aField.Update
      Next aField
   Next aStory

End Sub
Reply to topic    Frihost Forum Index -> Computers -> Software

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.