vbams-wordselectionparagraph

Select and copy all paragraphs in selection range word macro


I need all paragraphs that are selected and not even completely selected to be selected and copied. I just wouldn’t like to select them completely with the mouse and copy them.

I know how to select and copy one paragraph:

Sub Copy()
Selection.Paragraphs(1).Range.Select

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

but I need to select and copy all the paragraphs that are somehow affected in the selection.


Solution

  • Something like

    Dim r As Word.Range
    Set r = Selection.Range
    r.Expand wdParagraph
    ' If you actually need to copy, but maybe you could use r.FormattedText, depending on what you're trying to do.
    ' If you don't want to copy the paragraph mark, uncomment the
    ' following line
    ' r.End = r.End - 1
    r.Copy
    ' ...and eventually
    Set r = Nothing