View Single Post
  #3   Report Post  
Nexan
 
Posts: n/a
Default

Thanks, Graham! As far as the formatting goes, all I really need to do for
now is to select one specific paragraph and change it to bold.

"Graham Mayor" wrote:

The macro recorder is limited in its abilities and won't record formatting
information as part of the replace function. You'll have to add it manually
to the macro. What formatting do you want to replace?

The couple of examples below should help you sort it out:

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
Sub ReplaceExample2()

Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
'**********************
.Style = "Body Text"
.Replacement.Style = "FR1"
'**********************
.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


The second part is rather more complicated unless all the lines you want to
move are easily identifiable or you want to swap every three lines around -
See http://www.gmayor.com/replace_using_wildcards.htm


--

Graham Mayor - Word MVP

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




Nexan wrote:
I'm relatively new to Word macros, and I'm having two problems
relating to changing text.

The first is that I can't seem to get my macros to highlight all
instances of specific text and change its format. I know how to
record the action, and the action works as I'm recording the macro,
but not when I run it.

The second is that I can't get my macros to find all instances of a
paragraph, cut it, and paste it elsewhere in the document. A simple
example of what I'm trying to do:

I need to go from:

Line A
Line B
Line C

Line A
Line B
Line C

To:

Line B
Line C
Line A

Line B
Line C
Line A

I know how to specify the movement of paragraphs positioned at
specific lines, but this won't work well for this particular project
-- I'm having to make the same movements on a variable number of
blocks of text in the same document.

Thanks very much for your help!