![]() |
#1
|
|||
|
|||
![]()
I have some paragraph text copied from a text file. It contains blank lines (just returns). How can I find the total number of lines that contain text or punctuation, oe not blank. Thanks.
|
#2
|
|||
|
|||
![]() Code:
Sub test_text() Dim s As Shape, z&, lc& Set s = ActiveShape If s Is Nothing Then Exit Sub If s.Type <> cdrTextShape Then Exit Sub lc = 0 ' line's counter For z = 1 To s.Text.Story.Lines.Count If Len(s.Text.Story.Lines(z).Text) > 1 Then lc = lc + 1 ' or ' If s.Text.Story.Lines(z).Characters.Count > 1 Then lc = lc + 1 Next MsgBox lc & " non-empty lines" End Sub Last edited by shark; 13-04-2015 at 06:40. |
#3
|
|||
|
|||
![]()
Thanks for the suggestion. I had tried something similar but the problem is that a line with just one character is ignored. Trim doesn't help with returns being counted. I also tried lenB but it appears an empty line and a line with 1 character have the same number of bytes as well. Looks like I will need to make a copy convert to artistic text break apart and count the number of lines that way.
|
#4
|
|||
|
|||
![]()
I figured it out. I got some inspiration from reading your post. This works
Code:
Sub TestLines() Dim z As Shape Dim t As text Dim LN As Long If ActiveSelection.Shapes.Count = 0 Then Exit Sub Set z = ActiveShape If z.Type <> cdrTextShape Then Exit Sub Set t = z.text LN = 0 For i = 1 To CStr(t.Story.Lines.Count) If z.text.Story.Lines(i).text <> Chr(10) And z.text.Story.Lines(i).text <> Chr(13) _ And Len(z.text.Story.Lines(i).Characters.all) >= 1 Then LN = LN + 1 Next i MsgBox LN & " lines containing text" End Sub |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Small Text Character Count Bug X4 SP2 | runflacruiser | CorelDRAW/Corel DESIGNER VBA | 4 | 24-05-2011 09:55 |
Remove blank space in Paragraph text | runflacruiser | CorelDRAW/Corel DESIGNER VBA | 8 | 20-10-2010 19:01 |
Convert Paragraph to Artistic - error on blank Paragraph Text Field | gorgo2 | Macros/Add-ons | 3 | 14-09-2010 06:53 |
Macro - loading a blank template file *.cdt for Grahic and Text styles | gorgo2 | Macros/Add-ons | 5 | 28-04-2010 00:25 |
Identifying specific lines of paragraph text | knowbodynow | CorelDRAW/Corel DESIGNER VBA | 3 | 06-12-2007 03:58 |