admin管理员组文章数量:1389754
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"
本文标签: How to Assign to quotVariable Listquot Type of Visio Shape Data in VBAStack Overflow
版权声明:本文标题:How to Assign to "Variable List" Type of Visio Shape Data in VBA - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744734740a2622257.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