![](/img/trans.png)
[英]select a range of text from one Word doc using vba and copy to end of another document and RETAIN formatting
[英]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
当您使用 Find 时,活动范围移动到 Found 范围。 要将其扩展到文档的末尾,您需要如下代码:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.