Shape Names Starting with a Number

Started by PiP, May 18, 2019, 07:52:19 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

PiP

Hello,

I am struggling to understand how to reference shape properties in a shapesheet, the issue being I have use leading numbers in the names that I have created for the shapes e.g. "8_TxW1"

It appears when I have a leading number I need to enclose the reference to it with single quote marks - i.e. '8_TxW1', whereas if it is just letters no quotes required.

This took me an age to work out as I had renamed the shape from a previous name that did not have leading text, and whilst everything looked like that name was accepted, the shape sheet would only refer to the old name even though the drawing explorer etc. showed it as not existing.

I also note that when I refer by ID, the shapesheet will recognise sheet7!, (no period), but does not recognise sheet.7! (period included) which is what all the reference material appears to inform is the correct syntax for referencing.

This might all be old news, but interested to know if I am missing something?  While I seemed to have got it all working, I can possibly recreate and upload a file if of interest.

Are there any (other) shape naming conventions I should give consideration to?  Is there benefit fixing meaningful shape names that sit 'behind' the masters?

Regards

PiP

Nikolay

#1
May this confusion come from Name and NameU?
See, each shape has two names. One you can see in the UI (in the "Shape Name" window for example or the drawing explorer).

Another one (NameU) is hidden. But when you name a shape for the first time, using the dialog, both names are set.
But later on, if you modify the "public" name, the "hidden" NameU is not modified.

Note that in the ShapeSheet formulas, you can only use the "hidden" NameU to refer to a shape.

I think there must be been a good reason for this behavior.
For example, it allows ShapeSheet formulas to work even if an inquisitive user modifies shape name formulas still work.
Also, it allows you to freely name shapes in multiple languages while keeping formula references the same for all languages.

Note that NameU is not completely invisible; you can access it using the VBA for example.
Select a shape, switch to VBA and type in the interactive window:

?Selection(1).NameU

PiP

#2
Thanks Nikolay, that seems to explain it.

Any thoughts on good naming conventions or practices?

Regards,

PiP

PS the code snippet modified to "?activewindow.Selection(1).NameU"

Nikolay

#3
I don't think there are naming practices. Well maybe there are, it is just I have never heard of any :)

What I can think of is avoiding names that can be misinterpreted as a part of a ShapeSheet formula...
Like, names containing +/-/*/% (and similar special symbols), all sorts of quotes, names starting with digits, using unusual kanji characters (or emoji characters), and alike...
Basically, avoid anything that looks suspicious, and you'll be fine. Probably.

Also, you can't name shapes like Visio, i.e. you won't be able to name a shape like "Sheet.1"

BTW, thanks to the Unicode committee you can now actually call a file  ":) :) :).vsdx" and enjoy a brand new swarm of bugs!

PiP