Background:
I have a shape in Visio (basic Rectangle) that has assigned shape data (via right click->Data-> Define Shape Data). Two of these pieces of data, "Parents" and "Children" are of Type "Variable List". The intent is that "Parents" will list the names of all of the downstream shapes and "Children" will list the names of all the upstream shapes, to be controlled via macros. (NOTE: I know it seems backwards, but makes sense in the context of what the shapes represent)
Let's say I define one of these shapes in VBA, Dim myShape As Shape
. I also have more "Normal" (e.g. String, Number, Currency) data. For example. I have another shape datum, for example one called "Description" which is a simple text description of what the shape represents IRL.
I know I can assign the description value, via myShape.Cells("Prop.Description.Value").Formula = value
where value
is the string value I want to assign to it or is a string representing a formula incorporating other cells that work out to create the full string. For a numeric type, it can be a number or string formula that works out to a number.
Also, to note, if I return `myShape.Cells("Prop.Description.Type").Formula, I get 4, which is 'visPropTypeListVar', representing that the type is "Variable List".
Questions
Unfortunately, I can't seem to find any examples of how to work with this "Variable List" type. So, I have a couple of questions.
How do I assign the list or add list values to Prop.Parents? In other words, what do I need to do to format the data properly for the Variable List Type?
I also have a function,
resetProperties
which assigns the default values to all of the Shape Data. I want to assign an empty list toParents
andChildren
whenresetProperties
is ran, how would I do that?
Background:
I have a shape in Visio (basic Rectangle) that has assigned shape data (via right click->Data-> Define Shape Data). Two of these pieces of data, "Parents" and "Children" are of Type "Variable List". The intent is that "Parents" will list the names of all of the downstream shapes and "Children" will list the names of all the upstream shapes, to be controlled via macros. (NOTE: I know it seems backwards, but makes sense in the context of what the shapes represent)
Let's say I define one of these shapes in VBA, Dim myShape As Shape
. I also have more "Normal" (e.g. String, Number, Currency) data. For example. I have another shape datum, for example one called "Description" which is a simple text description of what the shape represents IRL.
I know I can assign the description value, via myShape.Cells("Prop.Description.Value").Formula = value
where value
is the string value I want to assign to it or is a string representing a formula incorporating other cells that work out to create the full string. For a numeric type, it can be a number or string formula that works out to a number.
Also, to note, if I return `myShape.Cells("Prop.Description.Type").Formula, I get 4, which is 'visPropTypeListVar', representing that the type is "Variable List".
Questions
Unfortunately, I can't seem to find any examples of how to work with this "Variable List" type. So, I have a couple of questions.
How do I assign the list or add list values to Prop.Parents? In other words, what do I need to do to format the data properly for the Variable List Type?
I also have a function,
resetProperties
which assigns the default values to all of the Shape Data. I want to assign an empty list toParents
andChildren
whenresetProperties
is ran, how would I do that?
1 Answer
Reset to default 1Assuming your cell is named "Parents" (name, not label - turn on the developer mode)
Try this:
' set list (three items, note semicolon and extra quotes)
shape.Cells("Prop.Parents.Format").FormulaU = """ParentA;ParentB;ParentC"""
' set value (select ParentB)
shape.Cells("Prop.Parents.Value").FormulaU = "INDEX(1,Prop.Parents.Format)"
' clear value
shape.Cells("Prop.Parents.Value").FormulaU = "No Formula"
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744734740a4590675.html
Collection
. You useAdd
to add items, andxxx[I]
to reference an element by index. To initialize, you assign a new object of the collection type. (Properties
, maybe?) – Tim Roberts Commented Mar 12 at 18:39