I am using CorelDRAW X7. I want to use a macro to break an artistic text into its indvidual characters (not curves).The demonstration macro below creates the string "123 456 789" and tries to do the breaking using BreakApartEx.But this only breaks the string at the spaces, and the ShapeRange, which the function BreakApartEx should produce according to "Help",only consists of a single shape containing "123", the other two shapes containing "456" and "789" are not members.By naming the original shape, I can break those up with more calls to BreakApartEx.So how should I procede to get a collection of all the individual characters (in this case nine)?How can I check wheather a string is breakable like the one given or not breakable (as "1")?CorelDRAW can distinguish the two cases: If I try breaking a string manually using the command "Object | Break Apart",then this command is active if the selected string contains more than one charakter, but grayed out otherwise.By the way, is it possible to *permanently* enable the button for "Macro Editor", some registry setting perhaps?
Sub BreakCreativeTextApart() Dim i As Long Dim AT As Shape, shp As Shape Dim Brk As ShapeRange Set AT = ActiveLayer.CreateArtisticText(20, 20, "123 456 789", , , "Times New Roman") AT.Name = "Digits" Debug.Print AT.Name, AT.Type Set Brk = AT.BreakApartEx For i = 1 To Brk.Count Debug.Print i, Brk.Item(i).Type Next i For Each shp In ActivePage.Shapes If shp.Name = "Digits" Then shp.BreakApartEx End If Next shpEnd Sub
I think it's the case that BreakApartEx doesn't work that way on text.
See this post on the Oberon Place forum for a description of the problem, and a description of one way to work around it.
Thank you, Eskimo, for the link, which indicates, that this is a bug.
I have experimented a little more, and written the function below, which does the breakup by naming the shape and counting the number of shapes with this name before and after the breaking-apart operations.
I added the statement sr.OrderReverse, but this does not produce what I expected: If the members of the shape range sr, initially were, say 1, 2, ..., N, then after the call to OrderReverse, the members would appear in the sequence N, N-1, ..., 2, 1. But apparently this is not what happens. So what is OrderReverse really doing?
Gosh, when answering this, I cant find the option to change the font of the function below to Courier, as I did yesterday! And selecting the text and using "Tools | Source code" produces gibberish.
Function BreakShapeApart(Expression As Shape) As ShapeRange Dim Token As String, shp As Shape, sr As New ShapeRange Dim CountBefore As Long, CountAfter As Long Token = Expression.Name Expression.BreakApartEx Do CountBefore = ActivePage.Shapes.Count For Each shp In ActivePage.Shapes If shp.Name = Token Then shp.BreakApartEx Next shp CountAfter = ActivePage.Shapes.Count Loop Until CountAfter = CountBefore For Each shp In ActivePage.Shapes If shp.Name = Token Then sr.Add shp Next shp sr.OrderReverse Set BreakShapeApart = srEnd Function