macro that automatically executes

T

Todd

How can I get a Word macro (stored in the document) to automatically execute
when the file is opened? I can write the macro to update the fields, i just
want it to do the update automatically (as I beileve it should anyway).
 
G

Greg Maxey

Todd,

In the documentment or document template, put something like

Sub AutoOpen()
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
End Sub
 

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