sub queryInfo
Selection.Find.ClearFormatting
With Selection.Find
.Text = "未读消息" + Chr(13)
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
If Selection.Find.Execute = True Then
receYear = Selection.Text
If receYear <> realInfo Then
Selection.Comments.Add Range:=Selection.Range
Selection.TypeText Text:="消息不正确"
End If
End If
''''''''''''''''''''''''''''''''调用判断已读消息
Call queryInfo_read
End SubSub queryInfo_read()
Dim myinfo as String
myinfo="已读消息"
Selection.Find.ClearFormatting
With Selection.Find
.Text = "已读消息"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
If Selection.Find.Execute = True Then
If curYear <> Selection.Text Then
Selection.TypeText Text:="已读消息不正确"
End If
End If
End Sub为什么我查询未读消息时,可以查询出来,并加批注,但是查询完未读消息后,调用queryInfo_read(),就查询不出来已读消息了。
Selection.Find.ClearFormatting
With Selection.Find
.Text = "未读消息" + Chr(13)
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
If Selection.Find.Execute = True Then
receYear = Selection.Text
If receYear <> realInfo Then
Selection.Comments.Add Range:=Selection.Range
Selection.TypeText Text:="消息不正确"
End If
End If
''''''''''''''''''''''''''''''''调用判断已读消息
Call queryInfo_read
End SubSub queryInfo_read()
Dim myinfo as String
myinfo="已读消息"
Selection.Find.ClearFormatting
With Selection.Find
.Text = "已读消息"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
If Selection.Find.Execute = True Then
If curYear <> Selection.Text Then
Selection.TypeText Text:="已读消息不正确"
End If
End If
End Sub为什么我查询未读消息时,可以查询出来,并加批注,但是查询完未读消息后,调用queryInfo_read(),就查询不出来已读消息了。
每次搜索都是从当前位置开始的,如果只有一个匹配项,那么第二次搜索当然没结果。
应该退到起始位置,再搜索。
If receYear <> realInfo Then
Selection.Comments.Add Range:=Selection.Range
Selection.TypeText Text:="消息不正确"
Selection.EscapeKey
End If
...