trante
trante

Reputation: 34006

MS Word macro, copying current paragraph text to clipboard

From this page I 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?

Upvotes: 1

Views: 9676

Answers (2)

Olle Sjögren
Olle Sjögren

Reputation: 5385

The following will copy your selection but checking for wdSelectionNormal will skip frames, shapes etc:

Selection.Paragraphs(1).Range.Select

If Selection.Type = wdSelectionNormal Then
    Selection.Copy
End If

Upvotes: 3

CuberChase
CuberChase

Reputation: 4518

You can move around the word using different units (ie wdParagraph, wdCharacter, wdLine). this will select the current paragraph and copy to the clipboard.

Sub SelectCurrentParagraph()
    Selection.StartOf Unit:=wdParagraph
    Selection.MoveEnd Unit:=wdParagraph
    Selection.Copy
End Sub

Upvotes: 3

Related Questions