![]() |
#15
|
|||
|
|||
![]()
Vivka,
I don't know if any of us here are professionals or if any of us have stopped learning from others. RobiNew, Vivka status flag is based solely on post count. I looked at the code you posted Vivka and have the following comments/suggestions: -I try to avoid GoTo -While what you posted seems to work for the OP, it seems that if a one line paragraph was nested with other one line paragraphs (not the first) then the OP stated conditions were not handled. -Rest of comments are inline with the code. Code:
Sub OneLinersII() 'In selection, replace Chr(13) with Chr(11) between all 'consecutive one-line paras, if.... Dim oPar As Paragraph 'If you dim one variable, why don't you dim all variables? Dim oRng As Range 'You declared the range object as a variant. Why not as a range? Application.ScreenUpdating = False Set oRng = ActiveDocument.Range For Each oPar In oRng.Paragraphs If oPar.Range.End >= oRng.End Then Exit For 'If you Exit Sub then you won't execute your ScreenUpdating line If Not oPar.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter _ And Not oPar.Range Like "*[0-9]*" Then If oPar.Range.ComputeStatistics(wdStatisticLines) = 1 Then Do While oPar.Next.Range.ComputeStatistics(wdStatisticLines) = 1 _ And Not oPar.Range.Next.ParagraphFormat.Alignment = wdAlignParagraphCenter _ And Not oPar.Next.Range Like "*[0-9]*" oPar.Range.Characters.Last.Text = Chr(11) Loop End If End If Next oPar Application.ScreenUpdating = True Set oRng = Nothing: Set oPar = Nothing lbl_Exit: Exit Sub End Sub Last edited by gmaxey; 11-08-2023 at 04:32 AM. |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Format Word Document - Remove timestamps on individual lines | lbeck | Word | 4 | 06-21-2023 12:47 PM |
How do I format indented bulleted lines??? HELP PLEASE!!! | nicholeproffitt | Word | 1 | 02-05-2015 05:42 PM |
![]() |
LaercioNB | Excel | 1 | 08-09-2013 06:03 PM |
How to remove unwanted lines - I cannot even find how/where they are inserted! | nickib | Word | 7 | 08-09-2013 06:01 AM |
![]() |
jcw | Word | 1 | 11-18-2011 11:47 AM |