Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Finding and Replacing using macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
chook.harel@gmail.com - 19 Jan 2006 13:31 GMT
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.
Dave Lett - 19 Jan 2006 13:58 GMT
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

> 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
[quoted text clipped - 25 lines]
>
> Please help me adjust the macro so it will work on the new program.
chook.harel@gmail.com - 20 Jan 2006 12:15 GMT
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)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.