|
我想单词在句子中还应考虑动词时态、名词复数等变化因素吧?看来楼主的想法还不够成熟。
我对英语并没多少研究,现根据楼主前面的说明对程序再作一次修改,希望能符合楼主的意思,至于其他问题,我无法解决。- Sub test5()
- Dim fs, f
- Dim findtext() As String, temp As String
- Dim i As Integer, c As Long, info As String
-
- Set fs = CreateObject("Scripting.FileSystemObject")
- With Application.FileDialog(msoFileDialogFilePicker)
- .Title = "请指定单词列表文本文件"
- .InitialFileName = ActiveDocument.Path
- .AllowMultiSelect = False
- If .Show <> -1 Then Exit Sub
- Set f = fs.OpenTextFile(.SelectedItems(1))
- findtext() = Split(f.ReadAll, vbCrLf)
- f.Close
- Set fs = Nothing
- End With
- With ActiveDocument.Content.Find
- For i = 0 To UBound(findtext)
- .MatchAllWordForms = IIf(findtext(i) Like "*[!A-Za-z]*", False, True)
- info = info & vbCrLf & findtext(i) & vbCrLf
- .Text = findtext(i)
- If .Execute Then
- c = c + 1
- With .Parent
- .Expand wdSentence
- temp = .Text
- If Right(temp, 1) <> Chr(13) Then temp = temp & vbCrLf
- If InStr(info, vbCrLf & temp) = 0 Then
- info = info & temp
- Else
- info = Replace(info, vbCrLf & findtext(i) & vbCrLf, "")
- info = Replace(info, vbCrLf & temp, "|" & findtext(i) & vbCrLf & temp)
- c = c - 1
- End If
- End With
- End If
- .Parent.WholeStory
- Next
- End With
- info = "共搜索到" & c & "条。" & vbCrLf & info
- Documents.Add.Content.Text = info
- End Sub
复制代码 |
|