Update all fields on saving/closing

J

Jason L

Hey, would anyone be able to pass on the code for updating all fields in a
template when the user closes and/or saves and closes?

Here is what I have so far:

ActiveDocument.Fields.Update

TIA,
Jason
 
H

Helmut Weber

Hi Jason,
you may intercept "filesave" and "filesaveas", like this:
Sub filesave()
Dim rStr As Object
For Each rStr In ActiveDocument.StoryRanges
rStr.Fields.Update
Next
ActiveDocument.Save
End Sub
---
But there is more to it.
First, updating fields plus closing without saving
doesn't make sense to me. So intercepting documentclose
combined with updating fields would be useless.
Second, updating fields in templates (!) doesn't make
much sense either.
Third, for processing really all (!) kinds of storyranges, see:
http://word.mvps.org/faqs/customization/ReplaceAnywhere.htm
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
J

Jason L

Helmut,

Yeah, not sure why I said that about closing without saving. That's kinda
silly.

As for updating fields in a template, I really meant documents based on a
template. Sorry for the poor wording.

-Jason
 

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