Microsoft Word宏来计算评论

时间:2012-08-16 12:10:55

标签: windows ms-office word-vba

我是一名教学设计师;我通过添加注释来编辑word文档。我问我是否可以找到一个Word宏来帮助我计算这些评论并对它们进行分类。 感谢您的帮助

1 个答案:

答案 0 :(得分:4)

以下是根据您的类别计算项目的Sub

Sub CountComments()
    Dim spelling, grammar, rephrasing, technical, other As Integer
    spelling = 0
    grammar = 0
    rephrasing = 0
    technical = 0
    other = 0

    Dim comment As comment
    For Each comment In ActiveDocument.Comments

        Dim firstWord As String
        firstWord = Split(comment.Range.Text, " ")(0)

        Select Case LCase(firstWord)
            Case "spelling"
                spelling = spelling + 1
            Case "grammar"
                grammar = grammar + 1
            Case "rephrasing"
                rephrasing = rephrasing + 1
            Case "technical"
                technical = technical + 1
            Case Else
                other = other + 1
        End Select
    Next

    MsgBox _
        "Spelling:" & spelling & _
        "; Grammar:" & grammar & _
        "; Rephrasing:" & rephrasing & _
        "; Technical:" & technical & _
        "; Other:" & other, , "Comment category summary"
End Sub