does shape data exist

Z

zzqv9p

I have this VB code that adds columns to a shape. It works fine once but then
fails on an exception when run a second time as the named row already exist.
I have gone through the SDK and it mentions a existrow property, but I can't
see how to apply it in the VB code.

Here is the code:
Sub set_shape_detailed_info()
'Sub set_shape_detailed_info(shape_number, attribute_Number, detail_text,
label_name)
' set shape detailed info
' inserts text on the shape

shape_number = 1
attribute_Number = 1
detail_text = "Hewlett Packard"
label_name = "Manufacturer"

Dim winObj As Visio.Window
Dim Visioshape As Visio.Shape
Dim selectObj As Visio.Selection
Dim celObj As Visio.Cell
Dim celFormula, MasterName As String
Set selectObj = Visio.ActiveWindow.Selection
If selectObj.Count = 0 Then
MsgBox "You must select the shape before running this macro."
Else
Set Visioshape = selectObj(shape_number)
'Declare and set up the Action section

If Visioshape.SectionExists(visSectionProp, 0) Then


Visioshape.AddSection (visSectionFirstComponent + i)
' need to check if row exist before doing the add
' or we need to delete the namedrow before adding it

Visioshape.AddNamedRow visSectionProp, label_name, 0
Visioshape.Cells("Prop.Manufacturer.Label").Formula = Chr(34) &
label_name & Chr(34)
Visioshape.Cells("Prop.Manufacturer.Prompt").Formula = Chr(34) &
label_name & Chr(34)
Visioshape.Cells("Prop.Manufacturer.Value").Formula = Chr(34) &
detail_text & Chr(34)
Visioshape.Cells("Prop.Manufacturer.SortKey").Formula = """None"""
End If



End If


End Sub
 
A

AlEdlund

Since you're working with custom properties(shape data) you might try
something like this

If visShape.CellExists("prop.abc", False) = True Then

msgbox "already have that shape data in place assigned"

End If
 

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