Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reject revisions based on style

Status
Not open for further replies.

hotprop

Technical User
Jan 3, 2004
3
EU
Hello all

I'm a raw noob in vba for Word 2010 on Windows7 but getting a lot done copying bits and bobs from google but this one I can't get to work and I don't understand why, this my latest effort, it runs and looks like it's done it but erm, doesn't. In short I want to reject revisions based on Paragraph style, the styles are currently deleted but show because of track changes, thanks.
Code:
Sub findreject()
'
' findreject Macro
'
'
    
    Selection.find.ClearFormatting
    Selection.find.Style = ActiveDocument.Styles("Listings_Name")
    With Selection.find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
Do While Selection.find.Execute
Selection.Range.Revisions.RejectAll
Loop
End Sub
 
Try something based on:
Code:
Sub Demo()
Dim oRev As Revision
With ActiveDocument
  For Each oRev In .Revisions
    If oRev.Style = "Listings_Name" Then oRev.Reject
  Next
End With
End Sub

Cheers
Paul Edstein
[MS MVP - Word]
 
Good morning Paul and thank-you

That certainly looks sleeker

Sadly when i run that I get the following:

'Run-time error 5852

Requested object is not available'

Debug highlights 'If oRev.Style = "Listings_Name" Then'

Thanks again (this is rather pressing for me to fix)
Tynan

 
that suggests you have revisions that affect things other than text changes. Try adding:
On Error Resume Next
before:
If oRev.Style = "Listings_Name" Then oRev.Reject

Cheers
Paul Edstein
[MS MVP - Word]
 

or try this...
Code:
        If oRev.[b]Range.Style.NameLocal[/b] = "Listings_Name" Then oRev.Reject

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks gents, I'll try that in the morning although I ran out of time today and had to reject all changes, I'll have to go back later and remake a lot of the changes made earlier sadly

Rather a rude and non specific error init?

I have lots to learn and do in the immediate future along this sort of line ...

Thanks again
Tynan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top