Re: Replacing a whole paragraph
- From: "mpt" <mpt@xxxxxxxxx>
- Date: Thu, 02 Jun 2005 01:51:30 GMT
Dear Newzad,
Assume your text looks like this:
#1 The cat sat on the mat. The cat sat on the mat. The cat sat on the mat.
The cat sat on the mat. The cat sat on the mat. The cat sat on the mat. The
cat sat on the mat. The cat sat on the mat.¶
¶
#2 Now is the time for all good men to attend the next party. Now is the
time for all good men to attend the next party. Now is the time for all good
men to attend the next party. Now is the time for all good men to attend the
next party. Now is the time for all good men to attend the next party. Now
is the time for all good men to attend the next party. Now is the time for
all good men to attend the next party. Now is the time for all good men to
attend the next party. Now is the time for all good men to attend the next
party. Now is the time for all good men to attend the next party. Now is the
time for all good men to attend the next party. Now is the time for all good
men to attend the next party. Now is the time for all good men to attend the
next party. ¶
¶
#3 The cat sat on the mat. The cat sat on the mat. The cat sat on the mat.
The cat sat on the mat. The cat sat on the mat. The cat sat on the mat. The
cat sat on the mat. The cat sat on the mat
1 Start macro recording, name, assign shortcut keys.
2 Search for #2 and press Esc
3 Right arrow once.
4 Search for ¶¶ [use ^p^p in search window] and press Esc
5. Right arrow once (places cursor to left of "#3".)
6, Shift-ctrl-up twice.
7 Delete
8. Stop macro recording
This should allow you to delete #2 para no matter how long it is, provided
it always ends with two carriage returns. If more than two, alter step 2
appropriately.
Should get a macro that looks like this:
Sub Junk()
'
' Junk Macro
' Macro recorded 6/1/2005 by RO
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "#2"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^p^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdParagraph, Count:=2, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
End Sub
Hope this helps.
Richard
"Newzad Hirori" <nawzads@xxxxxxxxxxx> wrote in message
news:kNjne.26141$d5.176597@xxxxxxxxxxxxxxxxxx
> Dear Richard,
>
> The para. do begin with a constant #02 but its end is only determined by
> the para. sign. How many characters and blanks follow #02 is not fixed.
> What shall I do?
>
>
> "mpt" <mpt@xxxxxxxxx> skrev i meddelandet
> news:Ot6ne.22755$PS3.13349@xxxxxxxxxxxx
>> Newzad, if para. #2 does indeed start with "#2" (and the content is
>> uniform, say only one period at the end of the paragraph) I would create
>> a macro (alt-t-m-r) called "junk" and assign it to keyboard shortcut
>> ctrl-j.
>>
>> Then I would have it do the following:
>>
>> 1. search for the unique beginning to each paragraph you want to delete.
>> ("#2"?)
>> 2. escape
>> 3. search for period at end of paragraph.
>> 4. press right arrow until your cursor is to the left of "#3".
>> 5. press ctrl-shift and up arrow until para. #2 is highlighted, along
>> with its trailing carriage returns.
>> 6. delete
>> 7. stop macro recording.
>>
>> Now go to top of your document and press ctrl-j until all your deletions
>> are made.
>>
>> If the formatting of your #2 para. is not uniform or if there is not a
>> unique character combination at the beginning of the para, you're hosed
>> pretty much. In this event, you could perhaps search for every third
>> combination of two carriage returns (^p^p) and do something like I've
>> suggested.
>>
>> I hope this is the germ of a solution for you.
>>
>> Richard
>>
>> "Newzad Hirori" <nawzads@xxxxxxxxxxx> wrote in message
>> news:CVWme.26019$d5.176425@xxxxxxxxxxxxxxxxxx
>>> Dear all,
>>>
>>> Is there a way to find and replace a whole paragraph in Word? My
>>> document consists of many paragraphs like these:
>>>
>>> #01 article
>>>
>>> #02 author
>>>
>>> #03 source.
>>>
>>>
>>>
>>> What I want is to delete all occurrences of #02 in the document.
>>>
>>>
>>>
>>> - Newzad
>>>
>>>
>>
>>
>
>
.
- References:
- Re: Replacing a whole paragraph
- From: mpt
- Re: Replacing a whole paragraph
- From: Newzad Hirori
- Re: Replacing a whole paragraph
- Prev by Date: Re: INITIAL CAPS- all words
- Next by Date: Re: INITIAL CAPS- all words
- Previous by thread: Re: Replacing a whole paragraph
- Next by thread: Finding and removing duplicate words
- Index(es):
Relevant Pages
|