Macro help request concerning Text.

Hello,

While I've come to a better understanding of manipulating curve shapes, text is still a big hurdle for me. I try pretty hard to figure this stuff out on my own but seriously 50+ debug attempts on what should be a  very small and simple (stage within a larger) macro really breaks me down.

What I'm trying to do is select a collection of artistic text fields, add a comma to the end of each one, bring them all together into one field and reverse their order. I will briefly explain a bit better. The comma is enough, no space adding required. The "combine" function of DRAW works fine for bringing them all together into one field, but it puts them in the reverse order of what I need, which makes sense because C1 is created first, then C2 and so on - resulting in C10C9C8 etc. I thought I was on the right track in the Object Browser when I found the InsertAfter "class member", but I got nowhere with the VBA example provided in the (F1) CorelDRAW X7 Macros Help resource. The example at least showed me how to insert specified text at the end of a paragraph text, even though I use artistic text. That much isn't a big deal of course, but the real trouble is I do not understand stuff like "Set s = d..."  followed by Set t =s..." and how they interact in this example. This is the VBA help example:

VBA example

The following VBA example inserts the sentence This will be inserted last. after the paragraph text This is an example.

Sub Test()
 Dim d As Document
 Dim s As Shape
 Dim t As Text
 Set d = CreateDocument
 Set s = d.ActiveLayer.CreateParagraphText(3, 3, 5, 5, _
  "This is an example.")
 Set t = s.Text
 t.Story.InsertAfter ("This will be inserted last. ")
End Sub

In my attempts to use this example, one of many troubles was that of course I don't need to create a new document as I'm already working in one, so I managed to do away with that without ruining the Set s = d part, though I've probably forgotten how by now. Then there's the problem that I am dealing with a selection range of Text, so that introduces the "t" aspect. When I try to do stuff like "for each s in sr" or "for each t in sr" (if that is even possible), I can't get it to work.

Here is an image of what I'm trying to achieve at this stage within a larger macro:

All help is appreciated!

Parents Reply Children