i use the following for when I add a shape to a network
diagram.
you should consider also using the visio sdk on the msdn
group since it is common to run into problems when first
learning to add values to cells....
al
*********************************************************
Private Sub pagObj_ShapeAdded(ByVal visShape As IVShape)
Dim strShapeUniqueID As String
Dim intResult As Integer
Dim blnPropAdded As Boolean
Dim blnValueAdded As Boolean
Dim shpCell As Visio.Cell
On Error GoTo ErrorHandler
g_blnCostScan = False
blnPropAdded = False
' for everything that has a cost we want a uniqueid
and a date last modified
If visShape.CellExists("Prop.Cost", False) Then
' make sure a unique id is assigned to the shape so
' that we can save/recall it to/from the database
strShapeUniqueID = visShape.UniqueID
(visGetOrMakeGUID)
blnPropAdded = AddCustomProperty
(visShape, "DTModified", "DTModified", "DTModified",
visPropTypeDate, "", "DTModified", False, False, "DBSync")
If blnPropAdded = True Then
' Debug.Print "Prop added"
Set shpCell = visShape.Cells("prop.DTModified")
SetCellValueToString shpCell, Now
Else
' Debug.Print "Prop not added"
End If
blnPropAdded = False
' now create the database record
subCreatePropertyRecord (strShapeUniqueID)
' then fill it in
subCustPropRecUpdate strShapeUniqueID, visShape
End If
If visShape.CellExists("prop.ipaddress", False) And
Not visShape.CellExists("Prop.VLAN_Id", False) Then
' Debug.Print "shape has ip address and no vlan_id"
blnPropAdded = AddCustomProperty
(visShape, "VLAN_Id", "VLAN_Id", "VLAN_Id",
visPropTypeString, "", "VLAN ID", False, False, "Network")
If blnPropAdded = True Then
' Debug.Print "Prop added"
Set shpCell = visShape.Cells("prop.vlan_id")
SetCellValueToString shpCell, "100"
Else
' Debug.Print "Prop not added"
End If
End If
' Debug.Print "shape added"
ErrorHandler:
If Err > 0 Then
Debug.Print "Err in ShapeAddedEvent is " & Err & " " &
Err.Description
Resume Next
End If
End Sub