View Single Post
  #5   Report Post  
Graham Mayor
 
Posts: n/a
Default

Unfortunately, you cannot record the type of macro that searches for a word
and applies formatting. The formatting commands are not recorded, as you
will see if you examine the code in the macro editor.

The following code demonstrates how to do something similar using manual
editing of the macro. In this instance it looks for all text formatted as
Ariel/Bold/12 point and replaces with BookmanOldStyle/Italic/11 point.
Change the relative parts of the code to suit your requirements.

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




TexasBBQ wrote:
Graham,
Thanks for the response. I wiped the machine, installed XP and a full
version (not trial) of Office 2003, and all my other software. Same
problem, macro will not run. Let me revise that, the MACRO runs, but
does nothing (the screen races and jumps around the document like
it's running). So I learned it was most likely not a mistake I made
in editing that caused the problem. I have 2 freshly installed winXP
machines, one I imported old macros - they work fine, AND newly
macros won't work. The other machine, I didn't import the old
macros, but the a a newly recorded macro won't work.

I'm creating very simple macros. Search for a specific word in a
document, and replace it with the same word - but make it BOLD and
RED. Very simple stuff.

Now I'll jump below and answer your questions.

"Graham Mayor" wrote:

How did you import all your old macros?

**** I stored the macros in a document, the opened it on the new
machine, and used Macros/Organize and moved them to Normal.doc. The
work great.
Does this machine have the full version of Acrobat 7 installed? If
so, see http://www.gmayor.com/lose_that_adob...at_toolbar.htm

**** I only have adobe reader version 7 installed.
Not all the search functions are available to the macro recorder.
Some you

would have to create manually.
**** You read above the kind of simple macros I'm creating, is this
functionality available?
--

Graham Mayor - Word MVP

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




TexasBBQ wrote:
Problem: Office 2003 60 dya trial was pre-installed on my New
computer. I imported my old macros and they worked great. However,
I created a new macro, and made a mistake, so I went to the editor
to edit, and now the macro won't run, nor will any new macro that I
record. All the old macros still work. I'd generally be classified
as a power user, but I don't typically edit macros, I simply record
simple macros to find and highlight text in documents I'm
researching.

Solutions Attempted so far.
1) Deleted all macros, rebooted and started over. Same Result
2) Reimported old macros and tried again. Same Result
3) Uninstalled MS Word, rebooted, reinstalled. Same Result.

Any ideas?