Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2005

Tip: Looking for answers? Try searching our database.

macro that automatically executes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Todd - 17 Jan 2005 22:19 GMT
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).
Greg Maxey - 17 Jan 2005 22:37 GMT
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
Signature

Greg Maxey/Word MVP
A Peer in Peer to Peer Support

> 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).

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.