ariellata
New member
- Joined
- Dec 19, 2019
- Messages
- 1
- Programming Experience
- Beginner
Hi Everyone,
I need help in VB since I am not a coder.
Translation professionals around the world pass on to each other a Word Macro called GetTCStats 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 it yields "Requested object is not available" (Run-time error '5852') and when I open debugging it highlights the line "Select Case oRevision.Type"
In other documents I tested, it worked fine, and there's no error, but when I "step into" and hover the "Select Case" line, I see it has an "oRevision.Type = <Object variable or With block variable not set>" comment.
Is the object not set correctly? Can anyone help solve this issue?
Very grateful for any help,
ariellata
note: if I did not post according to posting guidelines, my apologies, I am new to this.
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
I need help in VB since I am not a coder.
Translation professionals around the world pass on to each other a Word Macro called GetTCStats 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 it yields "Requested object is not available" (Run-time error '5852') and when I open debugging it highlights the line "Select Case oRevision.Type"
In other documents I tested, it worked fine, and there's no error, but when I "step into" and hover the "Select Case" line, I see it has an "oRevision.Type = <Object variable or With block variable not set>" comment.
Is the object not set correctly? Can anyone help solve this issue?
Very grateful for any help,
ariellata
note: if I did not post according to posting guidelines, my apologies, I am new to this.
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