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.

Loop help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TRM - 14 Jan 2005 16:37 GMT
I have an Access routine, using automation to approve only deletinos in a
word document.  I am having a problem with certain documents getting stuck in
this loop.  Can someone else see why this might be happening?
         
              For Each oRvs In oApp.ActiveDocument.Revisions
                   If oRvs.type = wdRevisionDelete Then
                       oRvs.Accept
                   End If
               Next
THANKS in advance for your help!
Jezebel - 14 Jan 2005 21:52 GMT
With the latest round of updates, Microsoft have managed to introduce a
nasty problem into the way collections (some Word collections, anyway) are
handled. It used to be that For each ... Next was guaranteed to iterate
every member of the collection. This is no longer the case. It seems that
now, some actions taken on a collection member cause the collection to be
rebuilt, so the loop processes the first member endlessly.

Try this --

For i = 1 to oApp.ActiveDocument.Revisions.Count
   Set oRvs = oApp.ActiveDocument.Revisions(i)
   :

Next

> I have an Access routine, using automation to approve only deletinos in a
> word document.  I am having a problem with certain documents getting stuck in
[quoted text clipped - 6 lines]
>                 Next
> THANKS in advance for your help!
Klaus Linke - 14 Jan 2005 23:55 GMT
Hi Jezebel, TRM,

I don't know if it's a recent problem... There always have been problems with
some collections when you removed items from them while looping (while other
collections didn't mind).

With the revisions, I wouldn't have expected problems.
But revisions can be problematic to loop if some of the revisions are in tables.

If Jezebel's code doesn't work properly eiter, you might look if there are
tables in the problematic docs.
Maybe try to ignore the deletions for the time being, if they are in a table --
looking at .Information(wdWithInTable).

Just grasping at straws, but you could also try whether
    For Each oRvs In oApp.ActiveDocument.Revisions
          With oRvs
              If .Type = wdRevisionDelete Then .Accept
          End With
     Next
works better (making doubly sure that you refer to the same revision both
times).

Greetings,
Klaus

> With the latest round of updates, Microsoft have managed to introduce a
> nasty problem into the way collections (some Word collections, anyway) are
[quoted text clipped - 22 lines]
> >                 Next
> > THANKS in advance for your help!
TRM - 15 Jan 2005 05:59 GMT
Thank you both for your responses!  I appreciate it!  There is a small table
in the doc/template.  I'll "play" with both & respond back!

> Hi Jezebel, TRM,
>
[quoted text clipped - 48 lines]
> > >                 Next
> > > THANKS in advance for your help!

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.