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!

Re: Loop help by Jezebel

Jezebel
Fri Jan 14 15:52:39 CST 2005

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



"TRM" <TRM@discussions.microsoft.com> wrote in message
news:FC88925B-13FA-4162-BC31-400A63A733A8@microsoft.com...
> 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!



Re: Loop help by Klaus

Klaus
Fri Jan 14 17:55:55 CST 2005

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


"Jezebel" wrote:
> 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
>
>
>
> "TRM" wrote:
> > 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!
>
>



Re: Loop help by TRM

TRM
Fri Jan 14 23:59:02 CST 2005

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!

"Klaus Linke" wrote:

> 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
>
>
> "Jezebel" wrote:
> > 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
> >
> >
> >
> > "TRM" wrote:
> > > 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!
> >
> >
>
>
>