Why does the following module fall in an endless loop?

D

DJ Kim

Sometimes I forget to have all changes accepted before making my
revisions, when working in a collaborative environment.
What I do in such case is open up the "accept or reject changes..."
dialog box, go over the changes one by one, and accept changes made by
others and skip those made by myself, thus, making the document
showing only the changes I made.
As you can guess, this becomes a very cumbersome routine when the
document is long.

Therefore, I wrote the following code, which is supposed to accept
changes made by others.
However, it runs into an endless loop.
Could someone please tell me what's wrong?


===============================================================
Sub AcceptRevisionsByOthers()

Dim MyStoryRange As Range, MyRevision As Revision, DefaultAuthor As
String

DefaultAuthor = "myself"

For Each MyRevision In ActiveDocument.Revisions
If MyRevision.Author <> DefaultAuthor Then MyRevision.Accept
Next

For Each MyStoryRange In ActiveDocument.StoryRanges
For Each MyRevision In MyStoryRange.Revisions
If MyRevision.Author <> DefaultAuthor Then MyRevision.Accept
Next
Do While Not (MyStoryRange.NextStoryRange Is Nothing)
For Each MyRevision In MyStoryRange.Revisions
If MyRevision.Author <> DefaultAuthor Then
MyRevision.Accept
Next
Loop
Next MyStoryRange

End Sub
 
W

Word Heretic

G'day (e-mail address removed) (DJ Kim),

Do While Not (MyStoryRange.NextStoryRange Is Nothing)

has no exit as the story range isnt changed within that loop

(e-mail address removed) (DJ Kim) was spinning this yarn:
Sometimes I forget to have all changes accepted before making my
revisions, when working in a collaborative environment.
What I do in such case is open up the "accept or reject changes..."
dialog box, go over the changes one by one, and accept changes made by
others and skip those made by myself, thus, making the document
showing only the changes I made.
As you can guess, this becomes a very cumbersome routine when the
document is long.

Therefore, I wrote the following code, which is supposed to accept
changes made by others.
However, it runs into an endless loop.
Could someone please tell me what's wrong?


===============================================================
Sub AcceptRevisionsByOthers()

Dim MyStoryRange As Range, MyRevision As Revision, DefaultAuthor As
String

DefaultAuthor = "myself"

For Each MyRevision In ActiveDocument.Revisions
If MyRevision.Author <> DefaultAuthor Then MyRevision.Accept
Next

For Each MyStoryRange In ActiveDocument.StoryRanges
For Each MyRevision In MyStoryRange.Revisions
If MyRevision.Author <> DefaultAuthor Then MyRevision.Accept
Next
Do While Not (MyStoryRange.NextStoryRange Is Nothing)
For Each MyRevision In MyStoryRange.Revisions
If MyRevision.Author <> DefaultAuthor Then
MyRevision.Accept
Next
Loop
Next MyStoryRange

End Sub

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
Email: (e-mail address removed)
Products: http://www.geocities.com/word_heretic/products.html
Spellbooks: 728 pages of dump left and dropping...

The VBA Beginner's Spellbook: For all VBA users.
 

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