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:
The following VBA example inserts the sentence This will be inserted last. after the paragraph text This is an example.
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!
Sub Macro4trey86
Dim s As Shape, sr As ShapeRange, ResultStr As String
Set sr = ActiveSelectionRange: If sr.Count = 0 Then Exit Sub 'working with selected text shapes
Set sr = sr.ReverseRange ' inverse order. This string you may remove
ResultStr = ""
For Each s In sr
If ResultStr <> "" Then ResultStr = ResultStr & "," 'adding comma
ResultStr = ResultStr & s.Text.Story.Text ' adding text. If you selected non-text shape then get error
Next s
Set s = Activelayer.CreateArtisicText(1,1, ResultStr) 'creating new shape with result
End Sub
Hey, Shark!
Thanks for looking into this with me. This will help me understand strings better, as that method is new to me. However, I may be doing something wrong, or I may have missed something in my explanation. I'm getting an error on that last line which prevents anything from playing in the macro. Screenshot:
If I understood strings better I may be able to spot the issue, but at this time I do not.