Edit a master shape using C#

Started by razydroid, December 29, 2012, 06:10:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

razydroid

Hi All,

I am new to Visio & C#. I am trying to create a visio document & add a master shape from a stencil. The shape is a group of 4 rectangles. I want to know how can I get each element in this group programatically using C#.

So far I am able to bring the shape to the Visio file. But Since its a group I am not able to get any property of the individual elements in that group. I want to set text for each rectangles with different values.

So far my code looks like the following.


Visio.Document doc = application.Documents.Add(@"\example.vst");
Visio.Page page = application.Documents[1].Pages[1];
Visio.Documents vdocs = application.Documents;
Visio.Document visioStencil = vdocs.OpenEx(@"\sample.vss", (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenDocked);
Visio.Page visioPage = application.ActivePage;
Visio.Shapes visShapes = visioPage.Shapes;
//the following shape in the setensil is the group of 4 rectanle I was referring
Visio.Master visioConvMaster = visioStencil.Masters.get_ItemU(@"Conveyance");
Visio.Shape visioConvShape = visioPage.Drop(visioConvMaster, 4.25, 5.5);
//try to ungroup to get each -- but this also not helping.
visioConvShape.Ungroup();


Any idea how I should proceed further? If I could get the individual elements from this group or some way if I can iterate throught the master shape, then i should be able to read & set the values for each element . I am using Visual Studio 2012 professional & Visio 2010 Premium

Thanks in advance. 

Paul Herber

Rule 1: never ungroup!

Get the group shapes count from visioConvShape.Shapes.Count
Iterate through them as visioConvShape.Shapes[n]
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/