2012-08-16 70 views
1

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

回答

3

这里有一个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 
+0

谢谢西蒙的评论;我想知道是否可以过滤这些评论并将它们分类。例如,我们有4种类型的错误(拼写,语法,改写和技术),并且我将错误的类型写为注释的第一个单词。我需要一个宏来计算每类错误的事件数量,以便在评估问题中使用它,而不是手动计算它们。感谢您的回复。 – user1603146 2012-08-21 10:26:38

+0

@ user1603146,我已更新,向您展示解决分类问题的方法。 – 2012-08-22 02:00:53