Updating a date field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a file that contains a date field. I use this file all of
the time. I created a macro that inserts this file and when the file is
inserted, I have to manually update the filed by highlighting the field and
pressing the F9 key. This date field code should update itself
automatically, and it does if I open the original file, but does not when
it's inserted into another file, via a macro that I created. I thought I
could edit the macro to automatically update the field, but that doesn't work
either. Anyone know how this can be corrected?
 
I have created a file that contains a date field. I use this file all of
the time. I created a macro that inserts this file and when the file is
inserted, I have to manually update the filed by highlighting the field and
pressing the F9 key. This date field code should update itself
automatically, and it does if I open the original file, but does not when
it's inserted into another file, via a macro that I created. I thought I
could edit the macro to automatically update the field, but that doesn't work
either. Anyone know how this can be corrected?

Exactly how did you try to get the macro to update the field, and
where in the document is the field?

If you used ActiveDocument.Fields.Update, that will update only the
fields in the "main story" of the document, not those in headers,
footers, text boxes, or autoshapes. To get everything, you need code
like this:

Dim myStoryRange As Range

For Each myStoryRange In ActiveDocument.StoryRanges
myStoryRange.Fields.Update
Do While Not (myStoryRange.NextStoryRange Is Nothing)
Set myStoryRange = myStoryRange.NextStoryRange
myStoryRange.Fields.Update
Loop
Next myStoryRange
 
Why are you inserting this into another file using a macro? Have you
considered using AutoText instead?

See http://addbalance.com/word/datefields1.htm for information on the
different kinds of datefields and how to format them.

--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
Back
Top