×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

does shape data exist

does shape data exist

does shape data exist

(OP)
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
 

RE: does shape data exist

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close