【发布时间】:2018-12-22 13:21:49
【问题描述】:
我正在编写一个小脚本来检查我的 word 文档。检查过程的一部分是检查我是否使用了被禁止的词。我在 MS Access 中创建了一个数据库,并将该数据库加载到 Word 中。
不起作用的部分实际上检查是否使用了数据库中的单词之一。我正在循环每个句子并执行以下检查:
"RS" 是加载的数据库表,"Selection" = 活动句子,"Cword" 是禁用词的变量,在循环访问数据库表时会发生变化
'Word check
RS.MoveFirst
While Not RS.EOF
Cword = LCase(RS!Woord)
PCword = LCase(RS!Pre)
With Selection.Range.Find
.ClearFormatting
.MatchWildcards = True
While .Execute(FindText:=" " & Cword & " ", Forward:=True)
If .Found = True Then
Oms = RS!Omschrijving
ActiveDocument.Comments.Add(Selection.Range, Oms).Author = ComAut
VB_count = VB_count + 1
RS.MoveLast
End If
Wend
End With
Wend
'number check
With Selection.Range.Find
.ClearFormatting
.MatchWildcards = True
While .Execute(FindText:=" [0-9] ", Forward:=True)
If .Found = True Then
SingleNumber = Selection.Range
Tientallen = SingleNumber Mod 10
Hondertallen = SingleNumber Mod 100
Duizendtallen = SingleNumber Mod 1000
If SingleNumber <= 0 Or Tientallen = 0 And SingleNumber <= 100 Or Hondertallen = 0 And SingleNumber <= 1000 Or Duizendtallen = 0 And SingleNumber <= 12000 Then
ActiveDocument.Comments.Add(Selection.Range, "dit getal bij voorkeur voluit schrijven. Uitgezonderd van bijvoorbeeld leeftijden, exacte waarden, maten, temperaturen en percentages").Author = ComAut
End If
End If
Wend
End With
我希望它做的是查找句子中的每个禁用词,如果找到,添加带有小描述的评论。问题出在 with find 部分,因为我添加了该部分并且在它起作用之前。当我执行代码时,单词会冻结,我必须强制关闭它。
感谢任何帮助,因为这部分困扰了我很长时间
【问题讨论】: