Text. Replacment.Text

S

Steved

Hello from Steved
Is it posible please to use VBA for the below as you can
see i have put in 2 text, Replacement.Text in a macro. Can
I have this run as a VBA if not can I have it so I can
shorten this macro hence it
..Text = "(CABALLERO PETE*)(^13)"
.Replacement.Text = "\1 Voodoo Rhythm \2"
..Text = "(*HALBERG*)(^13)"
.Replacement.Text = "\1 Star Way \2"
and so on I several of these to do. Thankyou.

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "(*CABALLERO PETE*)(^13)"
.Replacement.Text = "\1 Voodoo Rhythm \2"
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "(*HALBERG*)(^13)"
.Replacement.Text = "\1 Star Way \2"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
End Sub
 
C

Charles Kenyon

Hi,

You need to let us know what it is you want your macro to do. For future
reference, questions about macros probably should be posted in
word.vba.beginners.

Also, which version of Word are you using?

You may find <URL: http://word.mvps.org/FAQs/General/UsingWildcards.htm>
useful, as well.
--

Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
S

Steved

Hello Charles from Steved [XP Office]

What i am hoping to acheive is find a word like CABALLERO
PETE which is a horses name. I have two paragraphs of
information about each horse, but it does not have the
breeding so in the case of CABALLERO PETE it is Voodoo
Rhythm which is put in at the end of the second paragraph.
I have several of these to do hence hoping to find a quick
way of input. Any Idea's would be appreciated.
Cheers

ps thanks for pointing me in the right direction for VBA.
-----Original Message-----
Hi,

You need to let us know what it is you want your macro to
do.
For future reference, questions about macros probably
should be posted in
word.vba.beginners.
 
C

Cindy M -WordMVP-

Hi Steved,

If I'm understanding your request correctly (and I'm not
really sure I do), then the answer is "No". You cannot
instruct Find/Replace to search and replace multiple things
in a single pass. You need a pass for each Find/Replace pair.
What i am hoping to acheive is find a word like CABALLERO
PETE which is a horses name. I have two paragraphs of
information about each horse, but it does not have the
breeding so in the case of CABALLERO PETE it is Voodoo
Rhythm which is put in at the end of the second paragraph.
I have several of these to do hence hoping to find a quick
way of input.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep
30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 
K

Klaus Linke

Hi Steve,

What you *can* do to simplify things is write a macro with two string arguments (the search text and the replacement text), and then
call that macro with different pairs of arguments:
Call YourMacro("CABALLERO PETE","Voodoo Rhythm")
Call YourMacro("HALBERG","Star Way")
....

Greetings,
Klaus
 
S

Steved

Klaus thankyou very much.
That is what I will do.
Cheers
-----Original Message-----

Hi Steve,

What you *can* do to simplify things is write a macro
with two string arguments (the search text and the
replacement text), and then
 

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

Top