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 / March 2006

Tip: Looking for answers? Try searching our database.

I cannot refer to fonts when find while recording a macro. Help.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Macro Neophyte - 08 Mar 2006 05:33 GMT
I'm trying to replace all instances of a given character with the same
character in Times New Roman. This is straightforward using Word's find and
replace feature. I have to do this often for several characters, so I tried
writing a macro for it. Unfortunately, the macro recorder wouldn't save any
font specifications, thus it replaced all instances of the character in
question with itself, withouth changing the font. In other words, the macro
does nothing. Is there some way to make this work?
Graham Mayor - 08 Mar 2006 08:16 GMT
You will have to insert the extra commands manually - something along the
lines of

Sub ReplaceExample()

 Selection.HomeKey Unit:=wdStory
   Selection.Find.ClearFormatting
   Selection.Find.Replacement.ClearFormatting
       With Selection.Find
'**********************
       .Text = ""
       .Font.Name = "Arial"
       .Font.Bold = True
       .Font.Size = "12"

       .Replacement.Text = ""
       .Replacement.Font.Name = "Times New Roman"
       .Replacement.Font.Size = "11"
       .Replacement.Font.Italic = True
'**********************
       .Forward = True
       .Wrap = wdFindContinue
       .Format = True
       .MatchCase = False
       .MatchWholeWord = False
       .MatchAllWordForms = False
       .MatchSoundsLike = False
       .MatchWildcards = False
   End With
   Selection.Find.Execute replace:=wdReplaceAll
End Sub

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> I'm trying to replace all instances of a given character with the same
> character in Times New Roman. This is straightforward using Word's
[quoted text clipped - 4 lines]
> withouth changing the font. In other words, the macro does nothing.
> Is there some way to make this work?
 
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.