automatic field updates

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
 
W

Word Heretic

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:
 
J

janie

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
 
D

Dayo Mitchell

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
 
W

Word Heretic

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:
 
D

Dayo Mitchell

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
 
G

Graham Mayor

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

janie

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?!
 
W

Word Heretic

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:
 
J

janie

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:


.
 

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