This seems like a simple thing but the answer is eluding me. I'm writing a macro that identifies a textbox within a group and places text in it. Here's the scenario:
The user selects a group of objects (grouped objects).The macro loops through the various shape objects within the group until it finds the paragraph frame and changes the story (text) in the box.The paragraph frame in all cases is a child (combined) object inside of a rectangle.When the rectangle with text frame are part of a larger group, my code has no trouble looping through and finding the text frame.But when the selection is only the rectangle with its child text frame, I can't figure out how make this determination and identify the text frame.If I group the rectangle/text frame combination, my code works just fine. But this is not always going to be the case.
So how can I make my macro find the text frame that is combined with a rectangle?
Hello Ric,
I would use a little CQL to find any paragraph text, return that to a ShapeRange and loop through it to change the text. So something like this:
Sub FindParagraphText() Dim srSelection As ShapeRange Dim srParagraphText As ShapeRange Dim sText As Shape Set srSelection = ActiveSelectionRange Set srParagraphText = srSelection.Shapes.FindShapes(Query:="@type = 'text:paragraph'") For Each sText In srParagraphText.Shapes sText.Text.Story = "Some New Text" Next sText End Sub
I would also recommend this type of question be posted to the developer area as more people writting macros would see it:Forums - Developer Area - CorelDRAW Community
Happy coding,
-Shelby
Hi, Shelby. This was my first post to the forum so I figured someone would point me in the right direction if I posted in the wrong area. Thanks for the tip.
And thank you for the coding help. Your example works perfectly!
®i©