vba MS Word 宏,将当前段落文本复制到剪贴板
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14706407/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MS Word macro, copying current paragraph text to clipboard
提问by trante
From this pageI found out how to create a macro that selects current paragraph text.
从这个页面我发现了如何创建一个选择当前段落文本的宏。
Sub SelectCurrentParagraph()
Selection.Paragraphs(1).Range.Select
End Sub
But I ned this: When I put cursor inside a paragraph, macro will select paragraph text and copy it to clipboard. How can I do this?
但是我这样做了:当我将光标放在段落中时,宏将选择段落文本并将其复制到剪贴板。我怎样才能做到这一点?
回答by CuberChase
You can move around the word using different units (ie wdParagraph, wdCharacter, wdLine). this will select the current paragraph and copy to the clipboard.
您可以使用不同的单位(即 wdParagraph、wdCharacter、wdLine)在单词中移动。这将选择当前段落并复制到剪贴板。
Sub SelectCurrentParagraph()
Selection.StartOf Unit:=wdParagraph
Selection.MoveEnd Unit:=wdParagraph
Selection.Copy
End Sub
回答by Olle Sj?gren
The following will copy your selection but checking for wdSelectionNormal
will skip frames, shapes etc:
以下将复制您的选择,但检查wdSelectionNormal
将跳过帧、形状等:
Selection.Paragraphs(1).Range.Select
If Selection.Type = wdSelectionNormal Then
Selection.Copy
End If