OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > Code Critique

Thread Tools Search this Thread Display Modes
Old 23-11-2010, 14:37
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default Quick and easy way to removes empty lines of text

I wrote this a little while ago.
I noticedd even artistic text of 2 lines has the possibility of having more empty lines.
Is there a better or faster way to remove any empty lines in an artistic text string.

PS. Is this a bug that artic teext can have these empty lines?


Option Explicit

Sub align()

Dim s As Shape, p As Page, sr As ShapeRange
Dim i As Integer, j As Integer
Dim shNewText As Shape, strNew As String
Dim x As Double, y As Double, w As Double, h As Double
ActiveDocument.ReferencePoint = cdrBottomLeft

For Each p In ActiveDocument.Pages
    Set s = ActivePage.Shapes.FindShape(, cdrTextShape) 'wasn't at first but npw locking and crashing here.
    If s.Text.Type = cdrParagraphText Then
            s.GetBoundingBox x, y, w, h
            For i = s.Text.Story.Lines.count To 1 Step -1
                If Len(s.Text.Story.Lines(i + 1).Characters.All) < 2 _
                Or s.Text.Story.Lines(i + 1).Characters.All = " " Then
                    Dim strTemp As String
                    strTemp = s.Text.Story.Lines(i).Characters.All
                    If strTemp = "" Then
                        strTemp = strTemp & " "

                    End If
                    s.Text.Story.Lines(i).Characters.All = VBA.Left(strTemp, Len(strTemp) - 1)
            End If
        Next i
        s.Text.Frame.VerticalAlignment = cdrBottomJustify
        s.SetSize w, h
        s.SetPosition x, y

    End If

Next p

End Sub
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Empty Text boxes causing Runtime 91 Object Variable not set PaulANormanNZ CorelDRAW/Corel DESIGNER VBA 2 21-08-2009 03:15
Removing lines of text knowbodynow CorelDRAW/Corel DESIGNER VBA 1 01-06-2008 11:01
Identifying specific lines of paragraph text knowbodynow CorelDRAW/Corel DESIGNER VBA 3 06-12-2007 03:58
leading (line spacing) between lines of artistic text that have different font size michael_maberly General 4 15-07-2007 12:07
Separate a text object into individual lines/words/characters? Alex FAQ 1 16-04-2007 22:14

All times are GMT -5. The time now is 09:30.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com