Thread: [Solved] Another simple macro problem
View Single Post
 
Old 06-08-2012, 12:29 PM
Ulodesk Ulodesk is offline Windows 7 64bit Office 2010 64bit
Word 2013 Expert Cert
 
Join Date: Sep 2009
Location: Virginia
Posts: 872
Ulodesk is on a distinguished road
Default Another simple macro problem

I have recorded a macro to remove all paragraphs from a document. I would like a macro with which I can remove them from only selected text. This is useful when I receive a document with an included paragraph or more pasted from teh web or a text document, with hard line returns on all lines.

However, even though I select some text before recording the macro, it invariably operates on the entire document. I know that some macros can operate on only a selection -- I have recorded several -- but I can make sense out of the differences. The language in my recording mirrors that in ones that operate globally on the document, starting with

Code:
Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
(although some of my macros start with Selection.WholeStory)

and end with
Code:
 
Selection.Find.Execute Replace:=wdReplaceAll
Every time I try to look up VBA terms, I get completely frustrated by the vast realm thereby encompassed.

I know this is really basic for anyone who has learned programming.

Thanks.
Reply With Quote