Consulting

Results 1 to 4 of 4

Thread: Counting the number of comments by authors

  1. #1
    VBAX Regular
    Joined
    Oct 2016
    Posts
    45
    Location

    Counting the number of comments by authors

    Hi all,

    I'm wondering if there is a way to count the number of comments by specific authors. I'm modifying a comment grid generator and have added an option to exclude comments by up to 3 specific authors in the grid.

    At the end, a little message box opens up that says "x comments found in the document".

    I would like to make x only count the authors who weren't excluded by the user.

    My thinking is that the easiest way is to subtract the number of comments by the excluded authors from the overall comment count:

    x = ActiveDocument.Comments.Count - (number of comments from author 1 + number of comments from author 2 + number of comments from author 3)
    I'm sure that there is an easy way to do this, but I'm too stupid to work it out!

    Thank you.

  2. #2
    VBAX Regular
    Joined
    Oct 2016
    Posts
    45
    Location

    Message box to display list of comment and revision authors?

    Me again...

    I'm hoping to be able to create a list of people who have commented on, or made tracked changes to, a document. It's part of something else I'm trying to tweak, but I should be able to work out what I need to do if anyone knows if there is a way have a message box open up and say:

    'The following people have made comments or revisions on this document:
    AuthorA
    AuthorB
    AuthorC...'

    Any help appreciated.

  3. #3
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Try:
    Sub DemoA()
    Dim StrCmnt As String, ArrAuth, i As Long, j As Long, k As Long
    StrCmnt = vbCr: ArrAuth = Array("Author1", "Author2", "Author3")
    With ActiveDocument
      For i = LBound(ArrAuth) To UBound(ArrAuth)
        k = 0
        For j = 1 To .Comments.Count
          With .Comments(j)
            If .Author = ArrAuth(i) Then k = k + 1
          End With
        Next
        StrCmnt = StrCmnt & vbCr & ArrAuth(i) & " - " & k
      Next
    End With
    MsgBox "Comment Count by Designated Author:" & StrCmnt
    End Sub
    and:
    Sub DemoB()
    Dim StrCmnt As String, StrRevn As String, i As Long
    StrCmnt = vbCr: StrRevn = vbCr
    With ActiveDocument
      For i = 1 To .Comments.Count
        With .Comments(i)
          If .Author <> "" Then
            If InStr(StrCmnt, vbCr & .Author & vbCr) = 0 Then
              StrCmnt = StrCmnt & .Author & vbCr
            End If
          End If
        End With
      Next
      For i = 1 To .Revisions.Count
        With .Revisions(i)
          If .Author <> "" Then
            If InStr(StrRevn, vbCr & .Author & vbCr) = 0 Then
              StrRevn = StrRevn & .Author & vbCr
            End If
          End If
        End With
      Next
    End With
    MsgBox "Comment Authors:" & StrCmnt
    MsgBox "Revision Authors:" & StrRevn
    End Sub
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  4. #4
    VBAX Regular
    Joined
    Oct 2016
    Posts
    45
    Location
    Paul, you are an absolute legend. Thank you so much!

Posting Permissions

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