Loop help

T

TRM

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!
 
K

Klaus Linke

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
 
T

TRM

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!
 

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