VBA

S

Steved

Hello from Steved
Is this possible in VBA

Kalsoy then paragragh, paragraph Without Fear.

If the word Kalsoy is found then ^p then ^p put Without
Fear.
As in the Below example

1st: 1 KALSOY 5137552X05 ( 6) 67.0 ELSHAM
SHEESEE FE 12 20) H(16 6 2) Without Fear

Thankyou.
 
D

Doug Robbins - Word MVP

Hi Steve,

I would suggest that you try and make your questions a bit less cryptic than
they are.

In this case do you want to append "Without Fear" the end of the second
paragraph following any paragraph in which the word "Kalsoy" appears.

What about if "Kalsoy" appears in two successive paragraphs. Do you want
"Without Fear" added to the second paragraph that contains Kalsoy and the
one after it?

Maybe this does what you want:

Dim myrange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="Kalsoy", MatchCase:=True, Wrap:=wdFindStop,
Forward:=True) = True
Set myrange = Selection.Range
myrange.MoveEnd wdStory
myrange.End = myrange.Paragraphs(2).Range.End - 1
myrange.InsertAfter "Without Fear"
Loop
End With

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
S

Steved

Hello Doug

Firstly Thankyou
In this case it is a word association and it will only
appear once.

Thanks
-----Original Message-----
Hi Steve,

I would suggest that you try and make your questions a bit less cryptic than
they are.

In this case do you want to append "Without Fear" the end of the second
paragraph following any paragraph in which the word "Kalsoy" appears.

What about if "Kalsoy" appears in two successive paragraphs. Do you want
"Without Fear" added to the second paragraph that contains Kalsoy and the
one after it?

Maybe this does what you want:

Dim myrange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="Kalsoy",
MatchCase:=True, Wrap:=wdFindStop,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

VBA 2
Formating bolded text exclusively. 0
Need help modifying code 0
Finding Hidden text in word VBA 2
Ranking 2
Gears 14
Is this possible with excel? 10
Convert Time to Text 2

Top