Automation of Shape Text via Text Fields

S

SWL Developer

I'm working on a macro in Visio2000 which creates a corresponding text shape
for a selected shape on the page.

I would like to insert a text field as the shape.text value so that it
references a custom property of the selected shape so that any time the
property is changed, the shape.text would also change.

What is the syntax for inserting a text field for the shape's text?
 
A

Al Edlund

this from the visio sdk available for free at msdn.microsoft.com
al



Private Function insertCustomPropertyField( _
ByVal vsoShapeCharacters As characters, _
ByVal strPropertyNameU As String, ByVal intFieldFormat As Integer) _
As Integer

' insertCustomPropertyField
'
' Abstract - This method inserts a custom property label and value into
shape text.
'
' Parameters
' vsoShapeCharacters Shape characters object
' strPropertyNameu Custom property cell name
' intFieldFormat VisFieldFormats value
'
' Return value Position of the last character in the inserted text

Dim intLabelBegin As Integer
Dim intLabelEnd As Integer
Dim intTextEnd As Integer
Dim strLabelNameU As String
Dim strLabel As String
Dim vsoTargetShape As Visio.shape
Dim vsoLabelCell As Cell

On Error GoTo insertCustomPropertyField_Err

' look up the label for this custom property
strLabelNameU = strPropertyNameU + ".Label"
Set vsoTargetShape = vsoShapeCharacters.shape
Set vsoLabelCell = vsoTargetShape.CellsU(strLabelNameU)
strLabel = vsoLabelCell.ResultStr(VisUnitCodes.visUnitsString)

' Add the label.
vsoShapeCharacters.Begin = vsoShapeCharacters.End
intLabelBegin = vsoShapeCharacters.Begin
vsoShapeCharacters.Text = strLabel
intLabelEnd = vsoShapeCharacters.End

' Add a tab separator between label and field
vsoShapeCharacters.Begin = vsoShapeCharacters.End
vsoShapeCharacters.Text = vbTab

' Add the custom property
vsoShapeCharacters.Begin = vsoShapeCharacters.End
vsoShapeCharacters.AddCustomFieldU strPropertyNameU, intFieldFormat

vsoShapeCharacters.Begin = vsoShapeCharacters.End
vsoShapeCharacters.Text = vbLf
intTextEnd = vsoShapeCharacters.End

' Set the label to bold and left-aligned text.
vsoShapeCharacters.Begin = intLabelBegin
vsoShapeCharacters.End = intLabelEnd

vsoShapeCharacters.CharProps(VisCellIndices.visCharacterStyle) = _
VisCellVals.visBold

vsoShapeCharacters.ParaProps(VisCellIndices.visHorzAlign) = _
VisCellVals.visHorzLeft

vsoShapeCharacters.End = intTextEnd

insertCustomPropertyField = vsoShapeCharacters.End

Exit Function
 
M

Mark Nelson [MS]

Visio 2003 has a feature called Custom Callouts that offers this
functionality. I point this out in case you are able to work with a copy of
2003 and see what the Shapesheet settings are in the callout shape. That
may give you some clues how to set up your shape in Visio 2000.
 

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