Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-04-2023, 07:23 AM
RobiNew RobiNew is offline Find and format lines of verse Windows 10 Find and format lines of verse Office 2016
Competent Performer
Find and format lines of verse
 
Join Date: Sep 2023
Posts: 200
RobiNew is on a distinguished road
Default

No, Vivka, that is not what I want to get. No merging of paragraphs, but replacing of "^p" with "^l" in consecutive one-line paragraphs, as in the new docx I have posted. Thanks!
Attached Files
File Type: docx Lines of verse2.docx (45.8 KB, 3 views)
Reply With Quote
  #2  
Old 11-04-2023, 08:15 AM
vivka vivka is offline Find and format lines of verse Windows 7 64bit Find and format lines of verse Office 2016
Expert
 
Join Date: Jul 2023
Posts: 293
vivka is on a distinguished road
Default

RobiNew, here you are, enjoy it!
Code:
Sub OneLiners()
'In selection, replace Chr(13) with Chr(11) between all consecutive one-line paras.

Dim oRng
Application.ScreenUpdating = False
Set oRng = selection.range
    For Each Para In oRng.Paragraphs
        If Para.range.End >= oRng.End Then Exit Sub
        If Para.range.ComputeStatistics(wdStatisticLines) = 1 And _
            Para.Next.range.ComputeStatistics(wdStatisticLines) = 1 Then
            Para.range.Characters.Last.text = Chr(11)
            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
Reply



Similar Threads
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
Find and format lines of verse Print table and on verse form vba 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
Find and format lines of verse Find and Replace multiple lines/paragraphs jcw Word 1 11-18-2011 11:47 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:25 PM.


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