automatic field updates

  • Thread starter Thread starter janie
  • Start date Start date
J

janie

I've inserted a field that inserts the filename and have
managed to automate an update of fields when the document
is printed. How can I get the filename to be
automatically updated when I save? Otherwise it's going
to be confusing, especially as an email attachment.
Any help on this would be great,
janie
 
G'day "janie" <[email protected]>,

Maybe something like

Public Sub FileSave()
Activedocument.Fields.Update
Activedocument.Save
End Sub


Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


janie reckoned:
 
thanks for the advice. Is there any way I can solve the
problem without going into VBA-world, it's a strange
thing I'm unfamiliar with and would probably mess up!
Any more help available?
janie
 
A gentle entry into VBA. See one of these links:

What do I do with macros sent to me by other newsgroup readers to help me
out?
I don't know how to install them and put them to use
http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm

Idiots Guide to Installing Macros
http://www.gmayor.com/installing_macro.htm

The macro Steve gave will intercept your save command and instead execute
the macro, which both updates fields and saves.

Although, I thought if the fields were in the headers/footers, a more
complicated macro was necessary?

DM
 
G'day Dayo Mitchell <[email protected]>,

You're right as usual Dayo. I usually use a View > Normal, View >
Print Layout to update H&F. Whoopsy :-)

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Dayo Mitchell reckoned:
 
Well, I'm clueless about macros, just repeating what I've heard....I thought
I had someone else's macro saved that did this, but turns out it's not that
simple. Switching into print preview on every save would be possible, but a
bit slow.

Okay, I found this macro from Graham Mayor via Google (a few times,
actually)--Janie, try this one.

Sub UpdateAll()
Dim oStory As Range
Dim oField As Field
For Each oStory In ActiveDocument.StoryRanges
For Each oField In oStory.Fields
oField.Update
Next oField
Next oStory
End Sub

Dayo
 
Steve's original method usually works, but sometimes fields can show a
marked reluctance to update - particularly fields in headers/footers. The
code you reproduced from Google was what I originally used in my website
article you quoted, and again works most of the time, but it has since been
updated to more forcibly update the fields.

His second method using print preview could also be coded as

Sub UpdateFieldsAnotherWay()
Options.UpdateFieldsAtPrint = True
Application.ScreenUpdating = False
PrintPreview = True
PrintPreview = False
ActiveDocument.ActiveWindow.View.Type = wdPrintView
Application.ScreenUpdating = True
End Sub

and again this works *most* of the time.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
thanks guys, I've tried using the macro but even though i
got it working my boss won't let me put macros in a
template across the whole network...doh!! Is there any
un-macro-ish solution?!
 
G'day "janie" <[email protected]>,

Nope! :-) Man, bosses huh!

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


janie reckoned:
 
tell me about it!! thanks anyway!
-----Original Message-----
G'day "janie" <[email protected]>,

Nope! :-) Man, bosses huh!

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


janie reckoned:


.
 
Back
Top