Hi, I have had a working macro that search a text for a string,
then selects the other part of the same sentence and change its font
and size.
The code is as follows:

Sub mac2()
For Each myStoryRange In ActiveDocument.StoryRanges
myStoryRange.Find.Execute FindText:="%%%", Forward:=True
myStoryRange.MoveEnd Unit:=wdParagraph, Count:=1

While myStoryRange.Find.Found
myStoryRange.Font.Name = "David"
myStoryRange.Font.Size = 12
myStoryRange.Find.Execute FindText:="%%%", _
Forward:=True, Format:=True
myStoryRange.Font.Name = "Times New Roman"
myStoryRange.Font.Size = 1
myStoryRange.Find.Execute FindText:="%%%", Forward:=True
myStoryRange.MoveEnd Unit:=wdParagraph, Count:=1
Wend

Next myStoryRange
End Sub
------------------------------

The enclosed macro worked on Windows98SE / Word97. But it doesn't on
XP/Word2003.

Please help me adjust the macro so it will work on the new program.

RE: Finding and Replacing using macro by DaveLett

DaveLett
Thu Jan 19 07:58:06 CST 2006

Hi,

Have a look at the article "Using a macro to replace text where ever it
appears in a document including Headers, Footers, Textboxes, etc." at
http://word.mvps.org/FAQs/MacrosVBA/FindReplaceAllWithVBA.htm

Also, if your macro doesn't work, then you should explain WHAT is not
working with the macro. Otherwise, we have nothing really to go on.

HTH,
Dave

"chook.harel@gmail.com" wrote:

> Hi, I have had a working macro that search a text for a string,
> then selects the other part of the same sentence and change its font
> and size.
> The code is as follows:
>
> Sub mac2()
> For Each myStoryRange In ActiveDocument.StoryRanges
> myStoryRange.Find.Execute FindText:="%%%", Forward:=True
> myStoryRange.MoveEnd Unit:=wdParagraph, Count:=1
>
> While myStoryRange.Find.Found
> myStoryRange.Font.Name = "David"
> myStoryRange.Font.Size = 12
> myStoryRange.Find.Execute FindText:="%%%", _
> Forward:=True, Format:=True
> myStoryRange.Font.Name = "Times New Roman"
> myStoryRange.Font.Size = 1
> myStoryRange.Find.Execute FindText:="%%%", Forward:=True
> myStoryRange.MoveEnd Unit:=wdParagraph, Count:=1
> Wend
>
> Next myStoryRange
> End Sub
> ------------------------------
>
> The enclosed macro worked on Windows98SE / Word97. But it doesn't on
> XP/Word2003.
>
> Please help me adjust the macro so it will work on the new program.
>
>

Re: Finding and Replacing using macro by chook

chook
Fri Jan 20 06:15:51 CST 2006

Your right, my bad.
The problem is that it can change the font but not the font size,
instead it changes it where there is several types (like Latin1 20pt)
or something like that ..
(Not the place where u usually change the size)