Home |
Search |
Today's Posts |
#1
|
|||
|
|||
How can I create a macro to find and replace text attributes?
Hello, I am working in Word 2003 and am trying to recreate a ton of macros we
had made in WP, one set of them involves finding a text attribute, or finding and replacing it with something else. I can obviously do this, one by one, with the find and replace commands...however, for some reason I can't get it to "stick" in the macro. Two examples of what I am trying to create would be: 1. Find next bold. 2. Find next underline and change to italics. anyone have any suggestions? thanks! |
#2
|
|||
|
|||
pubgal23 wrote:
Hello, I am working in Word 2003 and am trying to recreate a ton of macros we had made in WP, one set of them involves finding a text attribute, or finding and replacing it with something else. I can obviously do this, one by one, with the find and replace commands...however, for some reason I can't get it to "stick" in the macro. Two examples of what I am trying to create would be: 1. Find next bold. 2. Find next underline and change to italics. anyone have any suggestions? thanks! I'll guess that you're trying to use the macro recorder to make these macros. There's a bug in the recorder that prevents it from seeing formatting changes. See http://word.mvps.org/FAQs/MacrosVBA/...ordedMacro.htm, in the section titled "Fixing broken Replace macros", for how to fix the macros that come from the recorder. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org |
#3
|
|||
|
|||
Thanks! We couldn't figure out if we were doing something wrong, or if there
was a problem in the program...makes us feel better! thanks for the article, we'll see if we can fix it up! You've saved our sanity and many hours of wasted work, thanks! Christina "Jay Freedman" wrote: pubgal23 wrote: Hello, I am working in Word 2003 and am trying to recreate a ton of macros we had made in WP, one set of them involves finding a text attribute, or finding and replacing it with something else. I can obviously do this, one by one, with the find and replace commands...however, for some reason I can't get it to "stick" in the macro. Two examples of what I am trying to create would be: 1. Find next bold. 2. Find next underline and change to italics. anyone have any suggestions? thanks! I'll guess that you're trying to use the macro recorder to make these macros. There's a bug in the recorder that prevents it from seeing formatting changes. See http://word.mvps.org/FAQs/MacrosVBA/...ordedMacro.htm, in the section titled "Fixing broken Replace macros", for how to fix the macros that come from the recorder. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org |
#4
|
|||
|
|||
Thew following provides an example of how formatting changes can be added to
the macro. 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 = "Bookman Old Style" .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 -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org pubgal23 wrote: Hello, I am working in Word 2003 and am trying to recreate a ton of macros we had made in WP, one set of them involves finding a text attribute, or finding and replacing it with something else. I can obviously do this, one by one, with the find and replace commands...however, for some reason I can't get it to "stick" in the macro. Two examples of what I am trying to create would be: 1. Find next bold. 2. Find next underline and change to italics. anyone have any suggestions? thanks! |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find and Replace feature when recording a Macro | Microsoft Word Help | |||
Mega macro with find and replace (HELP!) | Microsoft Word Help | |||
How do I find & replace "text form fields"? | Microsoft Word Help | |||
Find and Replace anomaly | Microsoft Word Help | |||
change all caps in text to small lettering using find and replace. | New Users |