Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Mar 2002
    Location
    Sunnvyale, California, USA
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Revisions in Word VBA problem (2000)

    Hi,
    I am trying to loop through all the revisions in a document and accept only those from a certain person. I'm having trouble when the revision is in a table cell. When I use Selection.NextRevision it selects the whole row of the table that contains the revision and then the Accept fails:

    Dim revRev as Revision
    On Error Resume Next
    Do While True
    Set revRev = Selection.NextRevision
    If InStr(UCase$(revRev.Author), "XYZ") > 0 Then ' ---> fails with Method 'Author' of object 'Revision' failed
    If Err.Number <> -2147467259 Then '---> a test for the above error
    revRev.Accept
    End If
    Err.Clear
    End If
    Loop

    So I tried explicitly stepping through the revisions:

    ilRevCt = ActiveDocument.Revisions.Count

    For i = ilRevCt To 1 Step -1
    If InStr(UCase$(ActiveDocument.Revisions(i).Author), "XYZ") > 0 Then
    ActiveDocument.Revisions(i).Accept
    End If
    Next i

    This one puts Word into an infinite loop (CPU cycles peg and I have to kill Word) when I step into the line with the If statement. I also tried a "For Each revRev In Selection.Range.Revisions" loop and it did the same thing as the first For loop I showed. I also noticed some weirdness with the Count of revisions changing (more than doubling) as I was single stepping through the code after getting the error, stopping the macro and restarting it.

    Is there just something funny about revisions in tables? I guess I could test for being in a table when I get the error and scan through the cells looking for revisions but that seems a bit painful?

    Thanks,
    Eric
    PS What characters do you use in submissions to the board to indent the code? Everything I can think of gets trimmed.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Revisions in Word VBA problem (2000)

    Revisions in tables are a problem, and it's more tragic than funny, as you can see.

    To maintain formatting in posts, use <!t>[pre]<!/t> before and <!t>[/pre]<!/t> after. Add syntactically appropriate wrapping as needed to minimize pain for those of more modest horizontal resolution.

    Four hours later...

    I just cannot make this work, either. Now matter how I "drill down," I can't get at the revisions in a table row as individual objects.

    Automating Dialogs(wdDialogToolsAcceptRejectChanges) also appears to be a dead end.

    Going back to the past, this seemed to work (it examines the current selection):

    <pre>If InStr(UCase$(WordBasic.ToolsRevisionAuthor$()), "XYZ") > 0 Then</pre>

    But I couldn't figure out the "WordBasic object" way to then accept the change. If you have Word 6 or Word 95, you could create a macro with this in it and open it in Word 97/2000 and see how it converts...

    <pre>ToolsReviewRevisions .AcceptRevisions</pre>

    Wish I could tell you more... I've got a macro that's broken the same way.

  3. #3
    Lounger
    Join Date
    Mar 2002
    Location
    Sunnvyale, California, USA
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Revisions in Word VBA problem (2000)

    Hi,
    Thanks for spending the time. I'll try to play with it this weekend, I think I have a laptop around here with Win 95. If I come up with something that works I will post it.

    Eric

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •