本文介绍了比较两个word文档&找不到。省略,缺失,添加单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
比较两个word文档&找不到。省略,缺失,添加单词
编辑 [从其他重复问题复制源代码 - Sascha Lefèvre]:
Compare two word document & Find no. of omitted,missing, added word
Edit [copied source code over from otherwise duplicate question - Sascha Lefèvre]:
Dim c As Integer = doc2.Sentences(1).Words.Count
Dim c1 As Integer = doc1.Sentences(1).Words.Count - 1
'Dim c1 As Integer = doc1.Sentences(2).Words.Count - 1
If c1 > c Then
b = 1
MsgBox("First")
For a = 1 To c - 1
'MsgBox(doc1.Sentences(1).Words(b).Text.Trim(" ").ToString() & "*****" & doc2.Sentences(1).Words(a).Text.ToString() & "*****")
If doc1.Sentences(1).Words(b).Text.Trim(" ").ToString() <> doc2.Sentences(1).Words(a).Text.Trim(" ").ToString() Then
b = b + 1
If doc1.Sentences(1).Words(b).Text.Trim(" ").ToString() <> doc2.Sentences(1).Words(a).Text.Trim(" ").ToString() And doc1.Sentences(1).Words(b + 1).Text.Trim(" ").ToString() <> doc2.Sentences(1).Words(a).Text.Trim(" ").ToString() Then
mistake = mistake + 1
b = b - 1
Else
added = added + 1
b = b + 1
End If
Else
b = b + 1
End If
Next
If added = 0 Then
added = added + 1
End If
ElseIf c1 < c Then
b = 1
MsgBox("Second")
For a = 1 To c - 1
'MsgBox(doc1.Sentences(1).Words(b).Text.Trim(" ").ToString() & "*****" & doc2.Sentences(1).Words(a).Text.ToString() & "*****")
If doc1.Sentences(1).Words(a).Text.Trim(" ").ToString() <> doc2.Sentences(1).Words(b).Text.Trim(" ").ToString() Then
b = b + 1
If doc1.Sentences(1).Words(a).Text.Trim(" ").ToString() <> doc2.Sentences(1).Words(b).Text.Trim(" ").ToString() And doc1.Sentences(1).Words(a).Text.Trim(" ").ToString() <> doc2.Sentences(1).Words(b + 1).Text.Trim(" ").ToString() Then
mistake = mistake + 1
b = b - 1
Else
omitted = omitted + 1
b = b + 1
End If
Else
b = b + 1
End If
Next
Else
MsgBox("Third")
For a = 1 To c
If doc1.Sentences(1).Words(a).Text <> doc2.Sentences(2).Words(a).Text Then
mistake = mistake + 1
End If
Next
End If
MsgBox("Mistake " & mistake & " Omitted " & omitted & " Added " & added)
推荐答案
这篇关于比较两个word文档&找不到。省略,缺失,添加单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!