delete line which contain spesfic word

  • Thread starter Thread starter Mubarak
  • Start date Start date
M

Mubarak

Hi there,

I have long word file and I need to delete any line which contain specific
word(s)

can I ?

Regards,
 
Is each line a separate paragraph? If so, it should be fairly easy
with a wildcard search.
 
yes it is a separate paragraph.

what do you mean by wildcard search?

example of the lines :
[ 4] local 10.0.7.2 port 5002 connected with 10.0.7.22 port 50167

the number is changed every time but I think if there is any way to search
with word "connected " and remove the holl line.

Regards,
 
(In playing card games, a "wild card" is a card that represents any
card at all.)

When you use Find/Replace (Ctrl-H), click More. You will see a box
"Use Wildcards." Choose that.

I do not myself know exactly how to code the wildcards, but in the
Find box you will need an expression that begins with the wildcard for
"Any number of characters," then the word "connected" then the same
"Any number" symbol, then ^13 (which is the code for end-of-
paragraph).

Leave the Replace With box empty. Test it with "Find Next" and
"Replace," and if it does what you want, then click "Replace All."

yes it is a separate paragraph.

what do you mean by  wildcard search?

example of the lines :
[  4] local 10.0.7.2 port 5002 connected with 10.0.7.22 port 50167

the number is changed every time but I think if there is any way to search
with word "connected " and remove the holl line.

Regards,



Peter T. Daniels said:
Is each line a separate paragraph? If so, it should be fairly easy
with a wildcard search.
 
The following macro should work

Sub DeleteParas()
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
While .Execute(findText:="connected", _
MatchWholeWord:=True)
Selection.Range.Paragraphs(1).Range.Delete
Wend
End With
End With
End Sub

http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

yes it is a separate paragraph.

what do you mean by wildcard search?

example of the lines :
[ 4] local 10.0.7.2 port 5002 connected with 10.0.7.22 port 50167

the number is changed every time but I think if there is any way to
search with word "connected " and remove the holl line.

Regards,

Peter T. Daniels said:
Is each line a separate paragraph? If so, it should be fairly easy
with a wildcard search.
 
Thank you Graham it is work but is cause some white space at the beginning
of the next line as bellow:

[ 4] 0.0-42.0 sec 24.0 KBytes 4.68 Kbits/sec
[ 5] 0.0-42.8 sec 24.0 KBytes 4.59 Kbits/sec
[ 6] 0.0-42.8 sec 24.0 KBytes 4.59 Kbits/sec
[ 4] 0.0-57.2 sec 1.23 MBytes 180 Kbits/sec
[ 5] 0.0-91.0 sec 1.12 MBytes 104 Kbits/sec
[ 8] 0.0-93.7 sec 584 KBytes 51.1 Kbits/sec

How I can delete this space?

and how can modify the macro to add another word also?

Regards,

Graham Mayor said:
The following macro should work

Sub DeleteParas()
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
While .Execute(findText:="connected", _
MatchWholeWord:=True)
Selection.Range.Paragraphs(1).Range.Delete
Wend
End With
End With
End Sub

http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

yes it is a separate paragraph.

what do you mean by wildcard search?

example of the lines :
[ 4] local 10.0.7.2 port 5002 connected with 10.0.7.22 port 50167

the number is changed every time but I think if there is any way to
search with word "connected " and remove the holl line.

Regards,

Peter T. Daniels said:
Is each line a separate paragraph? If so, it should be fairly easy
with a wildcard search.

On Jul 10, 7:24 am, Mubarak <[email protected]>
wrote:
Hi there,

I have long word file and I need to delete any line which contain
specific word(s)

can I ?
 
It might be simpler if you sent me a sample of the document and a list of
the words you want to search for
Send it to the link on the home page of my web site

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Thank you Graham it is work but is cause some white space at the
beginning of the next line as bellow:

[ 4] 0.0-42.0 sec 24.0 KBytes 4.68 Kbits/sec
[ 5] 0.0-42.8 sec 24.0 KBytes 4.59 Kbits/sec
[ 6] 0.0-42.8 sec 24.0 KBytes 4.59 Kbits/sec
[ 4] 0.0-57.2 sec 1.23 MBytes 180 Kbits/sec
[ 5] 0.0-91.0 sec 1.12 MBytes 104 Kbits/sec
[ 8] 0.0-93.7 sec 584 KBytes 51.1 Kbits/sec

How I can delete this space?

and how can modify the macro to add another word also?

Regards,

Graham Mayor said:
The following macro should work

Sub DeleteParas()
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
While .Execute(findText:="connected", _
MatchWholeWord:=True)
Selection.Range.Paragraphs(1).Range.Delete
Wend
End With
End With
End Sub

http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

yes it is a separate paragraph.

what do you mean by wildcard search?

example of the lines :
[ 4] local 10.0.7.2 port 5002 connected with 10.0.7.22 port 50167

the number is changed every time but I think if there is any way to
search with word "connected " and remove the holl line.

Regards,

:

Is each line a separate paragraph? If so, it should be fairly easy
with a wildcard search.

On Jul 10, 7:24 am, Mubarak <[email protected]>
wrote:
Hi there,

I have long word file and I need to delete any line which contain
specific word(s)

can I ?
 
Thanks! That macro is cool! :thumb:

To get rid of white space at the beginning of lines, find "^p^w", replace "^p"

It works on all but the first line, which might easily be done manually.
 
Back
Top