How to Assign to "Variable List" Type of Visio Shape Data in VBA - Stack Overflow

Background:I have a shape in Visio (basic Rectangle) that has assigned shape data (via right click->

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.

  1. 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?

  2. I also have a function, resetProperties which assigns the default values to all of the Shape Data. I want to assign an empty list to Parents and Children when resetProperties 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.

  1. 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?

  2. I also have a function, resetProperties which assigns the default values to all of the Shape Data. I want to assign an empty list to Parents and Children when resetProperties is ran, how would I do that?

Share Improve this question asked Mar 12 at 18:19 TrashmanTrashman 1,5962 gold badges20 silver badges33 bronze badges 2
  • In almost every case, a list like this is derived from a VBA Collection. You use Add to add items, and xxx[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
  • @TimRoberts I guess this question is specific to the Visio app, generic VBA thoughts won't help here. – Nikolay Commented Mar 12 at 19:47
Add a comment  | 

1 Answer 1

Reset to default 1

Assuming 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

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信