Results 1 to 11 of 11
  1. #1
    Lounger
    Join Date
    Oct 2004
    Location
    Indianapolis, Indiana, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Searching revisions of particular authors (Word 2000)

    I've created the folowing code to cycle through the tracked revisions of a single author. It works the way it ought to, but not the way I want it to:
    <pre>Sub FindCX()
    Dim name As String
    name = InputBox("Who's corrections do you want to find?")
    Dim objRevision As Revision
    For Each objRevision In ActiveDocument.Range.Revisions
    If objRevision.Author = name Then
    objRevision.Range.Select
    If MsgBox("Cliick OK to continue." & vbCrLf & "Click Cancel when you find what you're looking for.", vbOKCancel) = vbCancel Then
    Exit Sub
    Else: Selection.Collapse (wdCollapseEnd)
    End If
    End If
    Next objRevision
    MsgBox "That's all, folks!"
    End Sub
    </pre>


    As I said, it works the way it's supposed to. I type the name of the person whose tracked corrections I want to see (but I have to be exact!) and I can cycle through, revision-by-revision, and see each of that person's corrections. The problem is, because I used "For Each objRevision In ActiveDocument.Range.Revisions," it always starts from the beginning of the text.

    Any advice on how I can get it to cycle thorugh a particular person's revisions from the current selection?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Searching revisions of particular authors (Word 2000)

    If you use ActiveDocument.Range(Selection.Start, ActiveDocument.Range.End).Revisions instead of ActiveDocument.Range.Revisions, the search will start at the current selection, and proceed until the end of the document. It won't loop back.

  3. #3
    Lounger
    Join Date
    Oct 2004
    Location
    Indianapolis, Indiana, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Searching revisions of particular authors (Word 2000)

    It didn't work. It still starts at the beginning of the file.

    In the code you gave me in the previous message, Selection.Start always resolves to Selection.start, so I'm guessing the problem iis in this area somewhere. Any ideas?

    Also, to make this code even better, do you (or does anyone) know a *quick* way to access the author names for all of the revisions tracked in a document? I would love to have this macro offer the user a list of names to choose from so he/she doesn't have to precisely type in the name he/she wants.

    Moving those names into a list on a form is no biggie, but I don't know how to access those author names without a huge amount of slow code.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Searching revisions of particular authors (Word 2000)

    I just tested it - the code works correctly for me: the search starts at the beginning of the current selection (or at the insertion point). Of course, Selection.Start always resolves to Selection.Start, but perhaps you meant something else?

    Here is a macro to list all revision authors:

    Sub ListRevisors()
    Dim col As New Collection
    Dim rev As Revision
    Dim itm As Variant
    On Error Resume Next
    For Each rev In ActiveDocument.Revisions
    col.Add Item:=rev.Author, Key:=rev.Author
    Next rev
    For Each itm In col
    Debug.Print itm
    Next itm
    Set col = Nothing
    Set rev = Nothing
    End Sub

    Instead of printing to the Immediate window, you can fill a list box, or whatever you want to do with the items.

  5. #5
    Lounger
    Join Date
    Oct 2004
    Location
    Indianapolis, Indiana, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Searching revisions of particular authors (Word 2000)

    I meant that the S in Start always resolves to lowercase.

    Thanks for the code for extracting revision authors. I'll play around with it and see what I can do.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Searching revisions of particular authors (Word 2000)

    Do you have a variable named start (with a lower case s) somewhere (anywhere) in your code? That would cause all occurrences of Start to change to start.

  7. #7
    Lounger
    Join Date
    Oct 2004
    Location
    Indianapolis, Indiana, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Searching revisions of particular authors (Word 2000)

    Nope.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Searching revisions of particular authors (Word 2000)

    Sorry, no idea then, might be a fluke. But does Selection.Start work, or does it cause an error?

  9. #9
    Lounger
    Join Date
    Oct 2004
    Location
    Indianapolis, Indiana, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Searching revisions of particular authors (Word 2000)

    I just opened a brand-spankin-new module and tried this:

    Sub TestStart()
    ActiveDocument.Range(Selection.Start, ActiveDocument.Range.End).Select
    End Sub

    "Start" resolved to lowercase, but the macro worked as it should have. So the problem must be elsewhere.

    Thanks for your help, Hans.

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Searching revisions of particular authors (Word 2000)

    I wouldn't worry too much about the lower case s in start. I had this problem frequently in Office 97 VBA; it seems to have been solved in Office XP (I skipped 2000).

  11. #11
    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: Searching revisions of particular authors (Wor

    Does your project contain more than one kind of Selection object? If you open the Object Browser (F2) and search Selection in all libraries, maybe that would reveal it. You could avoid all ambiguity by using ActiveDocument.ActiveWindow.Selection.Start (but if it works as is, then that seems unnecessary).

Posting Permissions

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