leokuz 0 Light Poster

The macro below works, however I do not know how to make the removal of the paragraph marks (second portion of this macro) apply only to text it pastes, rather than to all existing text in the document. As it is right now, this macro pastes and then removes all of the paragraph marks from the whole document, rather than just from text it just pasts. Please help if you could.

Sub PasteUnformat()

' Paste unformatted text
    Selection.PasteSpecial Link:=False, DataType:=wdPasteText
    
    'Remove paragraphs
    
        Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "^p"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.