Microsoft KB Archive/269870

= WD2000: Font Is Not Changed When You Run Recorded Macro =

Article ID: 269870

Article Last Modified on 6/17/2005

-

APPLIES TO


 * Microsoft Word 2000 Standard Edition

-



This article was previously published under Q269870



SYMPTOMS
When you run a recorded macro that is designed to find text that is formatted in one font and change that text to a different font, the text is not changed to the new font.



CAUSE
Only formatting that is directly applied to text is recorded in a macro. The formatting that exists before the macro recorder is started is not coded into the macro, either. Therefore, you must manually add the specific names of the fonts used in a Find/Replace procedure, to the macro code in the Visual Basic Editor.



WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:

212536 OFF2000: How to Run Sample Code from Knowledge Base Articles

Modify your recorded macro to include the font name that you want to find by using the Font property, and the font name that you want to replace it with by using the Replacement property. Your modified recorded macro should look similar to the following example: Sub TestMacro

Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting

With Selection.Find .Text = &quot;&quot;

' Add the following Font Property and specify the name of the ' font you want to find. .Font.Name = &quot;Courier New&quot;

.Replacement.Text = &quot;&quot;

' Add the following Replacement Property and specify the name of     ' the font you want to replace with. .Replacement.Font.Name = &quot;Times New Roman&quot;

.Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchControl = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With

End Sub



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
For additional information about replacing font formatting, click the article number below to view the article in the Microsoft Knowledge Base:

209251 WD2000: Macro to Replace Font Formatting

