|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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. |
#2
|
||||
|
||||
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
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
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 |
stop carriage return or enter key in a table | Alaska1 | Word | 1 | 01-14-2013 08:48 AM |
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 |