View Single Post
 
Old 11-04-2023, 10:37 AM
vivka vivka is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Jul 2023
Posts: 293
vivka is on a distinguished road
Default

You are welcome, RobiNew! I'm not a professional. It's my hobby and I'm still learning. This forum is my university.
I realise that my macros are not perfect, but practice makes perfect.
The following code is two-lines shorter:

Code:
Sub OneLiners()
'In selection, replace Chr(13) with Chr(11) between all
'consecutive one-line paras.

Dim oRng
Application.ScreenUpdating = False
Set oRng = ActiveDocument.range
    For Each Para In oRng.Paragraphs
'Prevent returning an error if the next para is nothing:
        If Para.range.End >= oRng.End Then Exit Sub
        If Para.range.ComputeStatistics(wdStatisticLines) = 1 Then
            Do While Para.Next.range.ComputeStatistics(wdStatisticLines) = 1
                Para.range.Characters.Last.text = Chr(11)
            Loop
        End If
    Next
Application.ScreenUpdating = True
Set oRng = Nothing
End Sub
Reply With Quote