View Single Post
 
Old 11-04-2023, 01:13 AM
RobiNew RobiNew is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Sep 2023
Posts: 200
RobiNew is on a distinguished road
Default Find and format lines of verse

I have a tentative code to find consecutive one-line paragraphs (lines of verse) and to replace Chr(13) with (11) at the end of the line. I have uploaded a test docx. Can someone help? Thanks!
Code:
Sub LinesOfVerse()
    For Each Paragraph In ActiveDocument.Paragraphs
TypePara = "No"
NrPara = NrPara + 1
If Paragraph.Range.ComputeStatistics(wdStatisticLines) = 1 Then
    Paragraph.Range.Select
    Paragraph.Range.Characters.Last.Text = vbNullString
    Paragraph.Range.Characters.Last.Text = Chr(11)
    Paragraph.Range.Characters.Last.Text = vbNullString
    Paragraph.Range.Characters.Last.Text = Chr(11)
    TypePara = "Yes"
End If
If Paragraph.Range.ComputeStatistics(wdStatisticLines) = 1 _
And TypePara = "Yes" Then
    Paragraph.Range.Select
    Paragraph.Range.Characters.Last.Text = vbNullString
    Paragraph.Range.Characters.Last.Text = Chr(11)
    Paragraph.Range.Characters.Last.Text = vbNullString
    Paragraph.Range.Characters.Last.Text = Chr(11)
'    MsgBox "Check!"
End If
    Next
     End Sub
Attached Files
File Type: docx Lines of verse.docx (45.1 KB, 7 views)
Reply With Quote