Working with a Connect Object

3 4

A Microsoft Visio shape can be connected or glued to another Visio shape in a drawing. In the Visio object model, this relationship is represented by a Connect object. A Connect object represents a connection between two shapes in a drawing, such as a line and a box in an organization chart.

Figure 19-1.  <b>Connect</b> object and related objects higher in the Visio object model.

Figure 19-1 Connect object and related objects higher in the Visio object model.

Once you get a reference to a Connect object, you can find out which shapes are connected and how they are connected. You can also analyze directed graphs, such as flowcharts, or connected diagrams, such as organization charts, by getting properties of Connect objects for Shape, Master, and Page objects.

The Connects property of a Page object returns a Connects collection that includes a Connect object for every connection on the page. The Connects property of a Master object returns a Connects collection that includes a Connect object for every connection in the master.

A Shape object has two connection-related properties:

  • A Connects property, which returns a Connects collection that includes a Connect object for each shape, group, or guide that shape is glued to.
  • A FromConnects property, which returns a Connects collection that includes a Connect object for each shape, group, or guide glued to that shape.

For example, suppose a drawing contains two shapes named A and B and a one-dimensional (1-D) shape named C that connects A and B.

figure 19-2. two shapes connected by a 1-d shape.

Figure 19-2 Two shapes connected by a 1-D shape.

The Connects collection for A 's Connects property is empty. The Connects collection for A 's FromConnects property contains one Connect object that represents A 's connection from C. A is not glued to any shape (Connects property), but C is glued to A (FromConnects property).

The Connects collection for B 's Connects property is empty. The Connects collection for B 's FromConnects property contains one Connect object that represents B 's connection from C. B is not glued to any shape (Connects property), but C is glued to B (FromConnects property).

The Connects collection for C 's Connects property contains two Connect objects: one representing C's connection to A, and the other representing C 'sconnection to B. The Connects collection for C 's FromConnects property is empty. C is glued to A and B (Connects property), but no shape is glued to C (FromConnects property).

Or suppose a drawing contains four shapes named A, B, C, and D. Each shape has a control handle that is glued to a shape named E. In this case, shapes A, B, C, and D are connected to E directly via the control handle; the lines that show a hierarchical relationship between the shapes in this example are being drawn programmatically after the control handle is glued.

Figure 19-3.  The <b>Connects</b> collection of <b>E</b> is empty, because it is not glued to <b>A</b>, <b>B</b>, <b>C</b>, and <b>D</b>—they are glued to <b>E</b>. The <b>Connects</b> collections of <b>A</b>, <b>B</b>, <b>C</b>, and <b>D</b> each contain one <b>Connect</b> object.

Figure 19-3 The Connects collection of E is empty, because it is not glued to A, B, C, and D—they are glued to E. The Connects collections of A, B, C, and D each contain one Connect object.

To get the Connects collection of shape A, get the Connects property of that Shape object. For example:

 Set consObj = shpObj.Connects 

The Connects collection of shape A contains one Connect object that represents A 's connection to E. This is also true of the Connects collections of shapes B, C, and D. The Connects collection of shape E is empty, because it's not glued to the other shapes—they are glued to it.

Summary of properties for determining connections

Object

Property

Returns

Shape, Page, or Master

Connects

A Connects collection that includes a Connect object for each shape that shape is glued to.

Shape

FromConnects

A Connects collection that includes a Connect object for each shape glued to that shape.

Connects collection or Connect object

FromSheet

The shape a connection or multiple connections originate from (the shape or shapes creating the connection).

Connects collection or Connect object

ToSheet

The shape one connection or multiple connections are made to (the shape or shapes receiving the connection).

Connect object

FromPart

The part of a shape a connection originates from (the part of the shape that creates the connection).

Connect object

ToPart

The part of a shape a connection is made to (the part of the shape that receives the connection).

Connect object

FromCell

The cell of a shape a connection originates from (the cell in the shape that creates the connection).

Connect object

ToCell

The cell of a shape a connection is made to (the cell in the shape that receives the connection).



Developing Microsoft Visio Solutions 2001
Developing Microsoft Visio Solutions (Pro-Documentation)
ISBN: 0735613532
EAN: 2147483647
Year: 2004
Pages: 180

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net