|
Sub 查找指定段落()
Dim myrange As range, x As Boolean, wdn As Document, wd As Document, str As String
x = False
Set wd = ActiveDocument
Set myrange = wd.range
Dim DataObj As New MSForms.DataObject
DataObj.GetFromClipboard
If DataObj.GetFormat(1) = True Then str = DataObj.GetText(1)
Do While x = False
With myrange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = str
.Execute
If .Found Then
myrange.Expand Unit:=wdParagraph
myrange.Copy
If wdn Is Nothing Then Set wdn = Application.Documents.Add
wdn.range(wdn.range.End - 1, wdn.range.End - 1).Paste
myrange.SetRange myrange.End, wd.range.End - 1
Else
x = True
End If
End With
Loop
End Sub
参考吧,我也不太会 |
|