Make a distinction between shapes type on a visio page

Started by Lazyman, October 04, 2020, 07:35:48 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Lazyman

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.

Paul Herber

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.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Lazyman

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.

Nikolay

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.

Lazyman

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?

Lazyman

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.

Nikolay

"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 '(' ?

Lazyman

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.

Surrogate

you want get or set value ?
Result used for get value becuase it is read-only property

Lazyman

I want to get the value of the property. I tried result, result("")

Yacine

Yacine

Lazyman