Group:  Microsoft Word ยป microsoft.public.word.vba.beginners
Thread: Macro find and delete

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Macro find and delete
"Hans G" <jj.gerritsen[ at ]hccnet.nl> 26.01.2006 19:09:26
Does anyone know how to make a macro that finds a text in a document and
selects from that point tot another point, also seeking.
For example:

In the text below, I want the macro select all the lines from A till (the
first) C and then delete that part, of replace it with.....

Hans

F

B

B

A

C

C

A

B

B

C

B

C

B

D

D

B

D

D

C

C

D

B

C

C

D

C

B

B

D

D

A

C

D

A

C

Z

B


RE: Macro find and delete
Dave Lett 26.01.2006 19:31:03
Hi Hans,

As long as you're sure that "A" and "C" are unique, then you can use the
following:

With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Text = "A*C"
.MatchWildcards = True
With .Replacement
.ClearFormatting
.Text = "Replace"
End With
.Execute Replace:=wdReplaceAll
End With
End With

HTH,
Dave

"Hans G" wrote:

[Quoted Text]
> Does anyone know how to make a macro that finds a text in a document and
> selects from that point tot another point, also seeking.
> For example:
>
> In the text below, I want the macro select all the lines from A till (the
> first) C and then delete that part, of replace it with.....
>
> Hans
>
> F
>
> B
>
> B
>
> A
>
> C
>
> C
>
> A
>
> B
>
> B
>
> C
>
> B
>
> C
>
> B
>
> D
>
> D
>
> B
>
> D
>
> D
>
> C
>
> C
>
> D
>
> B
>
> C
>
> C
>
> D
>
> C
>
> B
>
> B
>
> D
>
> D
>
> A
>
> C
>
> D
>
> A
>
> C
>
> Z
>
> B
>
>
>
Re: Macro find and delete
"Hans G" <jj.gerritsen[ at ]hccnet.nl> 26.01.2006 20:24:28
Great Thanks. Its less complex than I thought.

Hans


"Dave Lett" <DaveLett[ at ]discussions.microsoft.com> schreef in bericht
news:1241C708-9BF8-4DF9-9999-E89AE88088D6[ at ]microsoft.com...
[Quoted Text]
> Hi Hans,
>
> As long as you're sure that "A" and "C" are unique, then you can use the
> following:
>
> With Selection
> .HomeKey Unit:=wdStory
> With .Find
> .ClearFormatting
> .Text = "A*C"
> .MatchWildcards = True
> With .Replacement
> .ClearFormatting
> .Text = "Replace"
> End With
> .Execute Replace:=wdReplaceAll
> End With
> End With
>
> HTH,
> Dave
>
> "Hans G" wrote:
>
>> Does anyone know how to make a macro that finds a text in a document and
>> selects from that point tot another point, also seeking.
>> For example:
>>
>> In the text below, I want the macro select all the lines from A till (the
>> first) C and then delete that part, of replace it with.....
>>
>> Hans
>>
>> F
>>
>> B
>>
>> B
>>
>> A
>>
>> C
>>
>> C
>>
>> A
>>
>> B
>>
>> B
>>
>> C
>>
>> B
>>
>> C
>>
>> B
>>
>> D
>>
>> D
>>
>> B
>>
>> D
>>
>> D
>>
>> C
>>
>> C
>>
>> D
>>
>> B
>>
>> C
>>
>> C
>>
>> D
>>
>> C
>>
>> B
>>
>> B
>>
>> D
>>
>> D
>>
>> A
>>
>> C
>>
>> D
>>
>> A
>>
>> C
>>
>> Z
>>
>> B
>>
>>
>>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net