Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

does shape data exist

Status
Not open for further replies.

zzqv9p

Technical User
Mar 22, 2002
1
US
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
 
Take a look at the CellExists property. It will tell you if a cell with that name already exists.



John... Visio MVP - Visio.MVPs.org
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top