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 / July 2006

Tip: Looking for answers? Try searching our database.

Accepting deletions in a selected area

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
robot - 31 Jul 2006 09:04 GMT
Hello,

I use the following code to accept all deletions in the selected area of a
document with revision marks:

Dim r As Revision
For Each r In Selection.Range.Revisions
   If r.Type = wdRevisionDelete Then r.Accept
Next r

However, no matter what area I selected, the above code always accepts all
deletions in the *entire* document. What went wrong?

I use Office XP and Win XP pro. Suggestions are most welcome.
Jonathan West - 31 Jul 2006 13:30 GMT
> Hello,
>
[quoted text clipped - 10 lines]
>
> I use Office XP and Win XP pro. Suggestions are most welcome.

There is a bug in the Revisions collection, which I think was introduced in
Word 2002 - it is also there in Word 2003. Whatever you range you create a
Revisions collection for, the actual collection returned is the Revisions
collection for the whole document.

Therefore, you need to make an additional test in your code, whether the
revision's Range property is within the selection's range. Use the InRange
method to compare 2 ranges, or compare the Start and End properties of the
two ranges. Something like this

Dim r As Revision
For Each r In ActiveDocument.Range.Revisions
   If r.Inrange(Selection.Range) Then
       If r.Type = wdRevisionDelete Then
           r.Accept
       End If
   End If
Next r

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.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.