In how many ways can I change the attributes of a shape?

Started by PF4VisioGuy, September 01, 2018, 01:20:48 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

PF4VisioGuy

Hi guys

I am new with VBA and I am actually learning the COM for Vision in order to automate it coming from the Python side.
Could you please tell me in how many ways I can change the property of a shape?

I have seem examples like
Shape.Text="something"
but also like
connector.CellsSRC(1,23,10).FormulaU="16"

There seems to be multiple ways to do it. The two ones I could guess are the above,by my understanding one is by accessing the object directly and the other one by accessing the Shape sheet ..it is not clear for me if there are any other methods to do this and if they are accessing the same backend structure (shapesheet) or they are accessing different object properties

For instance I could change the text of the object like above but I could not identify the Text cell in the shapesheet of the shape

wapperdude

There is no "text" cell.  This post covers vaious methods to work with text and for selecting shapes, http://visguy.com/vgforum/index.php?topic=7638.0.

Most everything else happens directly in the shapesheet.  You use either cellsSRC().formula or cellsU().formula structures to place info into a cell and cell().resultXYZ structures to fetch the contents. All of these have variations.

WRT to programming, regardless of programming language, you need to understand how Visio works and its object model.  A good source for the workings is this V2002 reference:  https://docs.microsoft.com/en-us/previous-versions/office/developer/office-xp/aa201749(v%3doffice.10)  it takes you to Chap15 about programming, but I encourage you to look at all of the chapters as they cost onto work with shapes, text, and how they can be altered.

Regarding the object model, check this:  https://docs.microsoft.com/en-us/visualstudio/vsto/visio-object-model-overview?view=vs-2017

Finally, look at examples, and the SDK (free).  Most of this will be in VBA, so you'll have to translate.

Wapperdude
Visio 2019 Pro

PF4VisioGuy

Thanks a lot wapperdude!

You are saying there is no Text cell.
Can I understand that some of the properties of a shape like Text are directly accessible while others are in the ShapSheet?
Why was this separation made by the Visio's designers?

wapperdude

WRT Text cell:
http://visguy.com/vgforum/index.php?topic=6652.msg27664#msg27664
See replies 13 & 14 to this post:  http://visguy.com/vgforum/index.php?topic=8490.msg36845#msg36845

Text is an exception to the rule.  The characteristics of the next, font type, size, color, etc, are still shapesheet functions.  Parsing text is yet another story...as is resizing text to either fit the shape or make shape fit the text. 

BTW, there is no text shape either.  There are just shapes, all of which will have a textbox which contains the text. There are no stand-alone textboxes, they all have an "owning" shape.

Just think of text as a unique aspect of Visio, don't fight it it, accept it, and go from there. 

Wapperdude
Visio 2019 Pro

PF4VisioGuy