Turning on Update Fields/Links macro

K

Kamran

I need help writing a macro that will automatically turn on Update Fields,
Update Links, and turn on Field Shading Always when the document is opened.
Thanks.
 
G

Greg

Karman,

Something like:

Sub AutoOpen()

ActiveDocument.Fields.Update
ActiveWindow.View.FieldShading = wdFieldShadingAlways
Options.UpdateLinksAtOpen = True

End Sub

Note: The update fields is a one time shot.
 
G

Greg

Actually to update all fields, remove the line:
ActiveDocument.Fields.Update
from the code I sent earlier and replace with:

Dim oStory As Range
For Each oStory In ActiveDocument.StoryRanges
oStory.Fields.Update
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Fields.Update
Wend
End If
Next oStory
Set oStory = Nothing
 
K

Kamran

Thanks, Greg. I took your cue and added:

Options.UpdateLinksAtPrint = True
Options.UpdateFieldsAtPrint = True

I just needed to set Word options to update fields at printing, since most
regular users don't have them turned on (and don't even know what they're
for).

I'm not a programmer, but isn't there a way to write a macro that when you
open the document it sets options in the user's Normal.dot that sets Field
Shading to Always?
 
K

Kamran

I don't understand what this one does since I'm not a programmer. Maybe an
earlier question I just posted will simplify things.
 

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