View Single Post
 
Old 11-27-2014, 11:43 PM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

With due deference to Paul, who is a whizz with find and replacement strings, I don't think this one does what you intend. Nor is it entirely clear what you want to remove and what you want to keep.

From your description I assumed you wanted to keep the IMEI line and the NCK line and remove the other two lines
OR
Keep the IMEI line and the NSCK and SPCK lines and remove the NCK line,

so in the following macro I have provided code options to do either - http://www.gmayor.com/installing_macro.htm

Code:
Sub RemoveParas()
Dim oPara As Paragraph
Dim oRng As Range
    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(FindText:=Chr(11))
            oRng.Text = Chr(13)
            oRng.Collapse wdCollapseEnd
        Loop
    End With
    For Each oPara In ActiveDocument.Paragraphs
        oPara.Range.ParagraphFormat.SpaceAfter = 0
        
        'Option 1 ________________________
        'If Trim(oPara.Range.Words(1).Text) = "NCK" Or _
         Trim(oPara.Range.Words(1).Text) = "SPCK" Then oPara.Range.Delete
         '-------------------
         
         'Option 2
        If Trim(oPara.Range.Words(1).Text) = "NSCK" Then oPara.Range.Delete
        '--------------------
    Next oPara
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote