709-218-7927 The Landfall Garden House 60 Canon Bayley Road CANADA A0C 1B0 |
---|
Delete All Paragraphs This Style
Tuesday, June 7, 2011
From time to time I have occasion to remove globs of text from a document leaving bits behind.
For example, I might want to delete all “Normal" styled paragraphs and leave only the 'Heading " styled paragraphs behind.
This macro does the trick, regardless of the styles in use!
Sub DeleteAllParagraphsThisStyle()''' Place the text cursor in a paragraph, run the macro.
''' All paragraphs in that (selected) style will be removed from the document.
Dim strStyleName As String
strStyleName = Selection.Paragraphs(1).Range.Style
Dim lng As Long
For lng = ActiveDocument.Paragraphs.Count To 1 Step -1
If ActiveDocument.Paragraphs(lng).Style = strStyleName Then
ActiveDocument.Paragraphs(lng).Range.Delete
Else
End If
Next lng
End Sub
7092187927 CPRGreaves@gmail.com Bonavista, Friday, December 04, 2020 5:55 PM Copyright © 1996-2020 Chris Greaves. All Rights Reserved. |
---|