Hi visio guys,
I have a set of shapes on a page and iwant to access to only rectangle shapes. Is there a shape property that I can use to discriminate between rectangles, lines, etc.
Thanks.
If your shapes were created from a stencil shape called "Rectangle" then the shape Master name will be "Rectangle" and your code can check for this. However, if you used the drawing tools on the toolbar/ribbon then you are out of luck. All those shapes are just named "Shape.xxx" where xxx is a number.
Thank you Paul for your feedback. My shapes have been created from the toolbar. So, I will redraw via the basic stencil and try to catch the type from there. I will let you know.
Thks.
You can also mark the shape yourself by adding some custom property., like "type"
Yoh can add custom proertis using shape data window or shape sheet.
Thank you foryour feedbacks. I have redrawn my shapes from the stencils instead of the toolbar ribbon and now i can discriminate the shapes according to their types. Now I want to rename the shapes. Therefore, I have added a row (at index 4) in the "User defined cells" section of the shape sheet.
How can i refer to the value of this property? For other properties, I do: shape.Cells("name_of_the_property").FormulaU. Is it ok for user defined cells?
Hi, to reach the new property (called name) in the user defined section, I tried the instruction in python
shape.Cells("User. Name").Value
It does not work.
Any hint please? Thanks.
"Value" is not valid property. There is "Result" (or "Formula"/"FormulaU", depending on what you are after). You could try:
Cells("User.Name").Result("")
Without auto-complete and parameter information every single step becomes a *** adventure (c) Deadwood ;D That's one of the reasons why people still use VB to work with Visio
Or you have managed to make the python auto-suggest and show parameter info after you type '.' or '(' ?
Hi Nikolai, I have put
shape.Cells("User. Name").Result("" ) then Formula then Formula and I always get an error message.
Currently, the value of the user defined property is "MyShape"
I can get the value of quite all the properties in the shapesheet except those in the user section.
you want get or set value ?
Result (https://docs.microsoft.com/en-us/office/vba/api/visio.cell.result) used for get value becuase it is read-only property
I want to get the value of the property. I tried result, result("")
try
shape.Cells("User. Name").ResultStr("")
Cool, it is OK now. Thank you guys.