Add row of connection points based on entered quantity

I

IMeng

I am fairly new to VISIO VBA. Have created a rather complex shape and I need
to be able to enter a number into a custom prop. field and have that number
of connection points inserted vertically along the edge of the shape along
with text labels.

Please assist.

Much appreciated
 
A

Al Edlund

JuneTheSecondSan, is correct in that your request has several issues that
play into the solution that you are looking for. As an example do you want
the shape to expand in size, or remain the same size based on the number of
connections? What is the maximum number of connections that can be allowed
(1000?)?
Part of the process is also identifying the constraints to the solutions.
Al
ps June does some nice work
 
C

Chris Roth [MVP]

Hi IMeng,

If your shape will have a limited number of connection points (say less than
100), you can pre-build them into the shape, then set their location based
on the value in the custom property.

You can't hide connection points using the ShapeSheet, but you *can* stack
them on top of each other, which effectively hides them.

So say your shape needs 20 points. The other 80 would be stacked under
connection point #1. If the user the types in 50, another 30 will be pulled
into use. Smart formulas in the ShapeSheet will determine where to locate
the points, how to resize the shape, how to draw geometry, etc. This can be
complicated, but sometimes it's worth not having to link to VBA code.

If your number of points is open-ended, it's better to programmatically add
and remove connection point rows in the ShapeSheet.

--
Hope this helps,

Chris Roth
Visio MVP

Free Visio shapes:
http://www.visguy.com/category/shapes
Visio programming info:
http://www.visguy.com/category/programming/
Other Visio resources:
http://www.visguy.com/visio-links/
 
I

IMeng

Chris Roth said:
Hi IMeng,

If your shape will have a limited number of connection points (say less than
100), you can pre-build them into the shape, then set their location based
on the value in the custom property.

You can't hide connection points using the ShapeSheet, but you *can* stack
them on top of each other, which effectively hides them.

So say your shape needs 20 points. The other 80 would be stacked under
connection point #1. If the user the types in 50, another 30 will be pulled
into use. Smart formulas in the ShapeSheet will determine where to locate
the points, how to resize the shape, how to draw geometry, etc. This can be
complicated, but sometimes it's worth not having to link to VBA code.

If your number of points is open-ended, it's better to programmatically add
and remove connection point rows in the ShapeSheet.

--
Hope this helps,

Chris Roth
Visio MVP

Free Visio shapes:
http://www.visguy.com/category/shapes
Visio programming info:
http://www.visguy.com/category/programming/
Other Visio resources:
http://www.visguy.com/visio-links/




My shape will be limited in number of connection points. Max number 100.
The shape serves as a universal master upon which all other shapes will be
created. The shape must have a user-defined number of connection points to
represent physical connections on the device the shape represents. A wiring
diagram will consist of many of these shapes, each having a unique number of
connection points on the left vertical edge representing "inputs" and also a
unique number of connection points on the right vertical edge representing
"outputs". Each "input" and "output" will also have a text abbreviation of
the physical connector type represented. Such text will not be attached to
connectors but rather to the shape and aligned next to each connecion point.

That is interesting about the connection points being stacked up on top of
each other, I have noticed that and thought it was an alignment error.

I was hoping to use VBA to create an IF THEN loop that compared the text in
a Prop.InputUserText field and then returned the appropriate values to the
scratch section.

I am all for using the shapesheet when I can, I just wanted adding 100
connection points in the shapesheet.

Any ideas?
 
I

IMeng

Al,
Good point. I did not consider the shape autimatically adjusting its size
to accomodate the amount of connection points. That sounds very elegant.
Now that you mention it I would want that automation function. There will be
no need to adjust size in any direction other then vertically. The shapes do
not rotate and never will.

By the way, thank you for the fast response.
 
I

IMeng

JunetheSecond,
I hope I answered all your questions in my previous reply. I have put
together the following code without success:

Sub ConnectionPoinLoop()
Dim shpObj As Visio.Shape
Dim selObj As Visio.Selection
Dim intInput As Integer
Dim intOutput As Integer
Dim i As Integer
Dim o As Integer
Set celObjx = shpObj.Cells(connections.x)
Set celObjy = shpObj.Cells(connections.y)

intInput = shpObj.User.NumInputs.Value
intOutput = shpObj.User.NumOutputs.Value
For i = 1 To intInput - 1
shpObj.AddRow(visSectionConnectionPts, visRowConnectionPts +
i,visTagXPoint)
celObjx.Formula = "GUARD(0)"
celObjy.Formula = "GUARD(Connections.X1-User.InSpacing)"

Next i

For o = 1 To intOutput - 1
shpObj.AddRow (visSectionConnectionPts, visRowConnectionPts +
o,visTagYPoint)
celObjx.Formula = "GUARD(WIDTH)"
celObjy.Formula = "GUARD(Connections.Y1-User.OutSpacing)"

Next o

End Sub

Trying to add a row in the Connection Points Section and add a formula to
each added row until the row equals the number entered by the user.

I also need to delete rows if the user reduces the number. The problem is I
just discovered that VISIO VBA does not recognise the "greater than"
operator!

Any comments on my code would be greatly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top