Hello,
I need help in VB since I am not a coder, please bare with me if I do not describe well the issue.
Translation professionals use Sub GetTCStats() Macro for Word in order to count insertions and deletions made in a Word document with Track Changes.
In some documents, it does not work at all, and yields "Requested object is not available" (Run-time error '5852'). When I open the debugging dialog, it highlights the line "Select Case oRevision.Type"
In other documents I tested, I do not receive this error, or any other, and it does appear "to work", but when I "step into" and hover this specific line ("Select Case oRevision.Type") I see it has a "oRevision.Type = <Object variable or With block variable not set>" comment in the tooltip.
how can we update this to work in all cases?
Very grateful to you all, ariellata
Macro:
Sub GetTCStats() Dim lInsertsWords As Long Dim lInsertsChar As Long Dim lDeletesWords As Long Dim lDeletesChar As Long Dim sTemp As String Dim oRevision As Revision lInsertsWords = 0 lInsertsChar = 0 lDeletesWords = 0 lDeletesChar = 0 For Each oRevision In ActiveDocument.Revisions Select Case oRevision.Type Case wdRevisionInsert lInsertsChar = lInsertsChar + Len(oRevision.Range.Text) lInsertsWords = lInsertsWords + oRevision.Range.Words.Count Case wdRevisionDelete lDeletesChar = lDeletesChar + Len(oRevision.Range.Text) lDeletesWords = lDeletesWords + oRevision.Range.Words.Count End Select Next oRevision sTemp = "Insertions" & vbCrLf sTemp = sTemp & " Words: " & lInsertsWords & vbCrLf sTemp = sTemp & " Characters: " & lInsertsChar & vbCrLf sTemp = sTemp & "Deletions" & vbCrLf sTemp = sTemp & " Words: " & lDeletesWords & vbCrLf sTemp = sTemp & " Characters: " & lDeletesChar & vbCrLf MsgBox sTemp End Sub



Reply With Quote

