View Single Post
 
Old 01-07-2018, 09:55 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,138
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

This sounds fairly straightforward. Can we assume that the 'lines' you refer to are in fact paragraph's? There are no 'lines' in a Word document, other than as an artefact of text flow.
Code:
Sub Macro1()
Const strWord As String = "word to find"
Dim oRng As Range
Dim oFind As Range
    Set oFind = ActiveDocument.Range
    With oFind.Find
        Do While .Execute(FindText:=strWord, MatchCase:=True, MatchWholeWord:=True)
            oFind.End = oFind.Paragraphs(1).Range.End
            Set oRng = oFind.Next.Paragraphs(1).Range
            oRng = Replace(oRng, "(", "")
            oRng = Replace(oRng, ")", "")
            oFind.Collapse 0
        Loop
    End With
lbl_Exit:
    Set oFind = Nothing
    Set oRng = Nothing
    Exit Sub
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