2012-08-16 33 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