Reply
 
Thread Tools Display Modes
  #1   Report Post  
pubgal23
 
Posts: n/a
Default 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   Report Post  
Jay Freedman
 
Posts: n/a
Default

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   Report Post  
pubgal23
 
Posts: n/a
Default

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   Report Post  
Graham Mayor
 
Posts: n/a
Default

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and Replace feature when recording a Macro WCRicster Microsoft Word Help 1 August 18th 05 07:23 PM
Mega macro with find and replace (HELP!) DKM Microsoft Word Help 1 May 10th 05 06:15 PM
How do I find & replace "text form fields"? OneClothEar Microsoft Word Help 1 April 13th 05 10:15 PM
Find and Replace anomaly BruceM Microsoft Word Help 7 January 18th 05 05:47 PM
change all caps in text to small lettering using find and replace. Jackson State New Users 3 January 13th 05 06:41 AM


All times are GMT +1. The time now is 08:48 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"