我的程序:(VB的,C#也差不多,问题不出在语言,而是方法) Private Sub Command1_Click() Dim obj As New Word.Application Dim x As Integer Dim y As Booleanobj.Documents.Open "C:\test.doc" obj.Documents("test.doc").ActivateSelection.Find.ClearFormatting With Selection.Find .Text = "中国*公司" .Forward = True .MatchAllWordForms = False .MatchSoundsLike = False .MatchFuzzy = False .MatchWildcards = True End With
Private Sub Command1_Click()
Dim obj As New Word.Application
Dim x As Integer
Dim y As Booleanobj.Documents.Open "C:\test.doc"
obj.Documents("test.doc").ActivateSelection.Find.ClearFormatting
With Selection.Find
.Text = "中国*公司"
.Forward = True
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False .MatchWildcards = True
End With
Selection.Find.Executey = Selection.Find.FoundDim str As Stringstr = Selection.TextMsgBox CStr(y)
MsgBox strSet obj = NothingEnd Sub可以找到,但是,关闭程序后,再打开就找不到了,也就是说,查找后指针没有复位到文件头
假如test.doc中有3个符合的text,查找到3次后,关闭程序,再次打开,也找不到了。
请问如何才能使得指针复位到文件头呢?