You've gotta build a string:
dim frml as string
dim shp as Visio.shape
....
frml = "ShapeText([shape]!TheText)"
frml = replace( frml, "[shape]", shp.ID )
shp.Cells("Prop.Something").ResultStr(visNoCast) = frml
--
Hope this helps,
Chris Roth
Visio MVP
I took a look at the ShapeText function in the Visio SDK and it appears
I
should be able to reference the shape by name. However, when I tried
this
I
get a "Qualifier must be Collection" compile error after the "!"
Below is the macro code I am using - a slight variation on the ToSheet
example in the SDK. Please steer me in the right right direction.
Thanks -
Jeff
************************
Public Sub ToSheet_Example()
Dim vsoShapes As Visio.Shapes
Dim vsoShape As Visio.Shape
Dim vsoConnectTo As Visio.Shape
Dim vsoConnects As Visio.Connects
Dim vsoConnect As Visio.Connect
Dim intCurrentShapeIndex As Integer
Dim intCounter As Integer
Dim endpoint_Shape(2) As Variant
Dim endpoint_Shape_Text(2) As Variant
Dim endpoint_Shape_ID(2) As Integer
Set vsoShapes = ActivePage.Shapes
'For each shape on the page, get its connections.
For intCurrentShapeIndex = 1 To vsoShapes.Count
Set vsoShape = vsoShapes(intCurrentShapeIndex)
Set vsoConnects = vsoShape.Connects
'For each connection, get the shape it connects to.
For intCounter = 1 To vsoConnects.Count
Set vsoConnect = vsoConnects(intCounter)
Set vsoConnectTo = vsoConnect.ToSheet
'Print the ShapeName, ID, and Text of the shape the
'Connect object connects to.
endpoint_Shape(intCounter) = vsoConnectTo.Name
endpoint_Shape_ID(intCounter) = vsoConnectTo.ID
endpoint_Shape_Text(intCounter) =
ShapeText(vsoConnectTo.Name!TheText)
Debug.Print endpoint_Shape(intCounter),
endpoint_Shape_ID(intCounter)
Next intCounter
Next intCurrentShapeIndex
End Sub
:
The formulas have to be set by code, dynamicallly. The ShapeSheet
isn't
smart enough to let you do this.
There is a shape text formula:
ShapeText(Sheet.19!TheText)
which will get you the text of the shape with ID 19. Your code will
have
to
determine which shapes the connector is glued to. You figure that out
using
shpConnector.Connects(1).ToSheet.ID, for example.
--
Hope this helps,
Chris Roth
Visio MVP
I am trying to store in each of two custom properties
(beg_point_label
and
end_point_label) of a connector, a string that is the text (not the
name)
of
the shape connected to the respective endpoint of the connector.
This
would
be dynamic so that the stored value would change depending on which
shape
the
user glued the end. All help is appreciated.
Thanks.