Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-30-2015, 08:55 AM
CEMurphy4 CEMurphy4 is offline Adding a carriage return at end of each line, and then a blank space, after text entry complete Windows 10 Adding a carriage return at end of each line, and then a blank space, after text entry complete Office 2013
Novice
Adding a carriage return at end of each line, and then a blank space, after text entry complete
 
Join Date: Nov 2015
Posts: 1
CEMurphy4 is on a distinguished road
Default Adding a carriage return at end of each line, and then a blank space, after text entry complete

Is there a way to create a macro that will force add a carriage return at the end of each line of text, but which will skip lines that have an existing carriage return, such as at the end of a sentence? And, once complete, add a blank line after each line of characters? Please note, double space will not work.



It's an odd request, I know, but context may help:
I prepare scripts to be displayed on an open captioning sign (example here, though I'm not associated with the Kimmel Center). The sign requires a program that can only read text formatted to specific requirements. These requirements can mostly be handled by a Word template and standard formatting tools (e.g., font, size, width, all caps), with the exception of two: first, automatic carriage returns cause an error so there must be a manually entered return, and second, each line of text, including blank lines, must be followed by a completely empty line that includes a carriage return. Double space isn't read as an empty line when imported into the sign's display program, so I can't use that. Also, we sometimes have carriage returns already entered at the end of each line to improve readability or to mimic actor delivery, these can't be doubled. Any help is hugely appreciated. I spend HOURS just hitting 'enter' for some performances!

EXAMPLE:

To have the following display correctly on the sign, these lines:
RICHARD: Now is the winter of our discontent
Made glorious summer by this son of York;
And all the clouds that lowered upon our house
In the deep bosom of the ocean buried.


... must be formatted like this:
RICHARD: NOW IS THE WINTER

OF OUR DISCONTENT

MADE GLORIOUS SUMMER BY

THIS SON OF YORK;

AND ALL THE CLOUDS THAT

LOWERED UPON OUR HOUSE

IN THE DEEP BOSOM

OF THE OCEAN BURIED.
Reply With Quote
  #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: 21,963
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
Reply



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 10:07 PM.


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