VBA Word 从特定单词复制文本到文档末尾

VBA Word Copy text from specific word till the end of the document

我需要从特定单词(假设它是特定要求)复制文本到文档结尾。

我已经准备了可能解决问题的代码,但我不知道必须向 .text 添加什么才能使其按我的意愿工作。


Sub Copying()
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Format = False
    .Forward = True
    .MatchWildcards = True
    .Wrap = wdFindContinue
    .Text = "Specific Requirements"
    .Execute
  End With
  If .Find.Found = True Then .Copy
End With
End Sub

当您使用“查找”时,活动范围会移动到“已找到”范围。要将其扩展到文档末尾,您需要这样的代码:

Sub Copying()
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Format = False
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWildcards = False
    .Text = "Specific Requirements"
    .Execute
  End With
  If .Find.Found = True Then
    .End = ActiveDocument.Range.End
    .Copy
  End If
End With
End Sub