Thread: [Solved] VBA help
View Single Post
 
Old 07-07-2011, 11:19 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,512
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi needhelp,

If you study the Find/Replace options available through Word's user interface, you'll find that you can include the find text as part of the replacement text (ie Replace = ^&) , which can include a paragraph break (ie ^p). So, you can achieve what it appears you're after, using Find/Replace (ie without a macro), where:
Find = <br/>
Replace = ^&^p

The following revision to your macro achieves the same thing:
Code:
Sub Demo()
With Selection.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Text = "<br/>"
  .Replacement.Text = "^&^p"
  .Forward = True
  .Wrap = wdFindContinue
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = False
  .Execute Replace:=wdReplaceAll
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote