OberonPlace.com Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-07-2006, 23:34
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,791
Blog Entries: 15
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Working With Text

I have tried several variations of this to no avail. Would someone mind looking this over and let me know what I am doing wrong. The basic idea is I am trying to convert all selected text to single line artistic text. (Which is working) Then add the newly broken apart single lines of text back to the shaperange. (Which is not working, as seen by turning it green, it only selects the first line.)

To test this you need to create a couple lines of artistic text, and make one or two more then two lines.

Thanks,

Shelby
Code:
Sub WorkingWithText()

Dim s As Shape
Dim srSelection As ShapeRange

Set srSelection = ActiveSelectionRange

For Each s In srSelection
    If s.Type = cdrTextShape Then
        If s.Text.Type = cdrParagraphText Then s.Text.ConvertToArtistic
        If s.Text.Story.Lines.Count > 1 Then srSelection.AddRange s.BreakApartEx()
    End If
Next s

srSelection.ApplyUniformFill CreateCMYKColor(100, 0, 100, 0)

End Sub

Last edited by shelbym; 12-07-2006 at 09:50.
Reply With Quote
  #2  
Old 12-07-2006, 00:48
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

Well, the problem is with the BreakApartEx method. The way it works, it performs the break apart operation and then returns the list of selected shapes after the transaction. This works pretty well for most cases except for breaking apart text. When you select a textblock and run Ctrl-K on it, it will break it into lines (or words, characters) and leave only the first line selected. That's why BreakApartEx returns only one shape and not all the resulting lines (well, you guessed it - it's a bug).

The only workaround I can see is to determine what new objects are produced during all the BreakApart calls and then add them back to the range.

Here is a quick method to do this (it is quick to write but not as efficient as it could be to run ).

Code:
Sub WorkingWithText()
    Dim s As Shape
    Dim srSelection As ShapeRange
    Dim srStateBefore As ShapeRange
    Dim srStateAfter As ShapeRange
    Set srSelection = ActiveSelectionRange
    
    ' Get all the text objects before the operation
    Set srStateBefore = ActivePage.FindShapes(Type:=cdrTextShape)
    For Each s In srSelection
        If s.Type = cdrTextShape Then
            If s.Text.Type = cdrParagraphText Then s.Text.ConvertToArtistic
            If s.Text.Story.Lines.Count > 1 Then s.BreakApart
        End If
    Next s
    ' And now after the operation
    Set srStateAfter = ActivePage.FindShapes(Type:=cdrTextShape)
    
    ' Any new objects are the ones created by the BreakApart calls
    ' Remove all the "old" objects
    srStateAfter.RemoveRange srStateBefore
    
    ' Now we have the new objects only. Add them to the original range
    srSelection.AddRange srStateAfter
    
    srSelection.ApplyUniformFill CreateCMYKColor(100, 0, 100, 0)
End Sub
Reply With Quote
  #3  
Old 12-07-2006, 07:37
gingem
Guest
 
Posts: n/a
Default

Hi Shelby
By no means could I try to solve your problem but I have a question about what it does. By reading the question that you asked it seems like you are trying to create single line text like an engraving machine would use. Is this correct? If it is then how would you export the newly created artwork as it shows on the screen?
My reason for asking is that this would be invaluable for the engraving business to be able to send single line fonts straight from Corel.
By the way your macro for my alignment is saving me a ton of time! I really appreciate all of your work.
Reply With Quote
Reply


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
Striping a word down to the first letter only knowbodynow CorelDRAW/Corel DESIGNER VBA 9 19-04-2007 15:14
Adding text via VBA knowbodynow CorelDRAW/Corel DESIGNER VBA 2 03-03-2006 09:15
Text selection and sizing ddonnahoe CorelDRAW/Corel DESIGNER VBA 5 17-05-2005 13:19
format text dialog box implement graphicdesigner CorelDRAW/Corel DESIGNER VBA 5 22-12-2004 13:37
Reset text after text compression. Bellekom CorelDRAW/Corel DESIGNER VBA 2 05-05-2004 06:14


All times are GMT -5. The time now is 06:16.


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