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 / August 2005

Tip: Looking for answers? Try searching our database.

Working through all stories

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bear - 02 Aug 2005 20:19 GMT
Hello:

I have a question about this code:

Sub RefFieldUpdateAllStory()
' Written by Charles Kyle Kenyon 15 November 2001
' repaired with help from Jezebel 10 December 2004
' All Story Field Updater - Ref fields
 Dim oField As Field
 Dim oStory As Range
 For Each oStory In ActiveDocument.StoryRanges
 ' This goes into headers and footers as well as the regular document
   Do
   For Each oField In oStory.Fields
     If oField.Type = wdFieldRef Then
       oField.Update
     End If
   Next oField
   Set oStory = oStory.Next
   Loop Until oStory Is Nothing
 Next oStory
End Sub

I'm curious about the Do ... Until oStory Is Nothing loop. Isn't this
functionality inherent in the For Each oStory loop?

I mean, wouldn't this work?

Sub RefFieldUpdateAllStory()

Dim oField As Field
Dim oStory As Range

For Each oStory In ActiveDocument.StoryRanges
   For Each oField In oStory.Fields
     If oField.Type = wdFieldRef Then
       oField.Update
     End If
   Next oField
Next oStory

End Sub

I'd really like to know...

Bear
Jean-Guy Marcil - 02 Aug 2005 20:48 GMT
Bear was telling us:
Bear nous racontait que :

> Hello:
>
[quoted text clipped - 40 lines]
>
> I'd really like to know...

The  test it out yourself!

Try both versions it with a simple document, then again with a document with
different odd/even/first page headers/footers in multiple sections....

Then, *after* you have tested it, check out this page in case you need more
info:
   http://word.mvps.org/faqs/customization/ReplaceAnywhere.htm

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
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.