'* +++++++++++++++++++++++++++++++++++++++ '* Created By 守柔(ShouRou)@ExcelHome 2005-1-19 6:11:24 '仅测试于System: Windows NT Word: 10.0 Language: 2052 '^The Code CopyIn [ThisDocument-ThisDocument]^' '* -------------------------------------------------------------------------- Sub GetParagraph1()
Dim i As Paragraph, Doc As Document
On Error Resume Next '错误忽略
Application.ScreenUpdating = False '关闭屏幕更新
Set Doc = Documents.Add '新建一个空白文档,注意此DOC为活动文档
For Each i In Me.Paragraphs '在本文档(THISDOCUMET)的段落中循环
If InStr(i.Range, "胃病") > 0 Then '如果包括指定字符则
Selection.InsertAfter i.Range '活动文档的光标处插入该段落
End If
Next
Application.ScreenUpdating = True '恢复屏幕更新
End Sub
'----------------------
Sub GetParagraph2()
Dim i As Paragraph, Doc As Document, strPar As String, AllPar As String
On Error Resume Next
Application.ScreenUpdating = False
Set Doc = Documents.Add
For Each i In Me.Paragraphs
If InStr(i.Range, "胃病") > 0 Then
strPar = i.Range
AllPar = AllPar & strPar '将文本置于内存中,可以加快运行速度
End If
Next
Doc.Activate
Selection.InsertAfter AllPar '一次性插入内存中的所有文本
Application.ScreenUpdating = True
End Sub
'---------------------- 第二个问题麻烦大哥多写几句好吗? |