View Single Post
 
Old 12-02-2015, 11:53 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,384
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

Try the following:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Rng As Range
With ActiveDocument.Range
  .Text = UCase(.Text)
  With .Font
    .Name = "Arial"
    .Size = 12
  End With
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Format = False
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWildcards = True
    .Text = "[^13]{2,}"
    .Replacement.Text = "^p"
    .Execute Replace:=wdReplaceAll
  End With
  Set Rng = .Characters.First
  Do While Rng.End < .End - 1
  Set Rng = Rng.GoTo(What:=wdGoToBookmark, Name:="\Line")
  With Rng
    If .Characters.Last <> vbCr Then .InsertAfter Chr(11) & Chr(11)
    .Collapse wdCollapseEnd
  End With
  Loop
  With .Find
    .Text = "^13"
    .Replacement.Text = "^p^p"
    .Execute Replace:=wdReplaceAll
    '.Text = "^11"
    '.Replacement.Text = "^p"
    '.Execute Replace:=wdReplaceAll
  End With
  While .Characters.Last.Previous = vbCr
    .Characters.Last.Previous.Delete
  Wend
End With
Application.ScreenUpdating = True
End Sub
As coded, the macro leaves your text with manual line breaks within each paragraph separating the text. This allows Word to keep treating each paragraph as a unit. If you want actual paragraph breaks, un-comment the commented-out code lines. The macro also provides for setting the font name & size, plus capitalising the text. I'm not sure what you mean about 'width'.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote