Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 12-02-2015, 11:53 PM
macropod's Avatar
macropod macropod is offline Adding a carriage return at end of each line, and then a blank space, after text entry complete Windows 7 64bit Adding a carriage return at end of each line, and then a blank space, after text entry complete Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting Carriage Return rsrasc Word VBA 4 02-15-2015 11:23 PM
Plain Text Content Control - Losing Styling on Carriage Return kintap Word 0 07-16-2014 12:43 PM
Adding a carriage return at end of each line, and then a blank space, after text entry complete stop carriage return or enter key in a table Alaska1 Word 1 01-14-2013 08:48 AM
Adding a carriage return at end of each line, and then a blank space, after text entry complete Coding into a macro a carriage return sinbad Word VBA 6 02-27-2012 03:51 AM
Carriage Return Help UCHelp Word 1 04-04-2010 10:11 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:47 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft