Reputation: 1001
I have a shape object drawn as a 'group' with text as 'P0', The group object contains two other small shape objects with text as 'P1'.
How can i get the details of this group object such that i can have an access to the text of all three shape objects - 'P0', 'P1', 'P1'. Any help will be much appreciated.
Upvotes: 1
Views: 331
Reputation: 2698
Assuming that:
then the following would work:
//Some method to get your target shape
var shp = vApp.ActivePage.Shapes.ItemFromID[1];
shp.Characters.Text.Dump($"Group shape - ({shp.NameID})");
foreach (Visio.Shape s in shp.Shapes)
{
s.Characters.Text.Dump($"Sub shape - ({s.NameID})");
}
Note - the Dump
method is just an extension method in LINQPad, but you could replace this with Console.WriteLine or similar.
The above code would produce output similar to this (where I've changed the text of the second sub-shape to 'P2'):
Also, you could just use the Shape.Text
property directly, but any fields in the text won't be expanded. So to get the full text as the user sees it, you use Shape.Characters.Text
instead.
Upvotes: 2