Visio Guy

Visio Guy Website & General Stuff => User-submitted Stuff => Topic started by: wapperdude on May 17, 2018, 07:39:35 PM

Title: Page / Shape: Name vs NameU vs Index vs ID
Post by: wapperdude on May 17, 2018, 07:39:35 PM
Visio's handling of naming comes up frequently in a variety of posts.  So, what's going on???  Well, here are some links for the official statements:
Name vs NameU:  https://blogs.msdn.microsoft.com/visio/2006/07/27/name-and-nameu/ (https://blogs.msdn.microsoft.com/visio/2006/07/27/name-and-nameu/)
Shapes:  https://msdn.microsoft.com/en-us/vba/visio-vba/articles/shape-nameu-property-visio (https://msdn.microsoft.com/en-us/vba/visio-vba/articles/shape-nameu-property-visio)
Pages:  https://msdn.microsoft.com/en-us/vba/visio-vba/articles/page-nameu-property-visio (https://msdn.microsoft.com/en-us/vba/visio-vba/articles/page-nameu-property-visio)

To illustrate the relationships for pages as listed in the post title, the following simple macro was used to check out page naming conventions.  The process involved:
1) new document, adding 3 pages to get a total of four.  Keep default (original) names and order.
2) run macro.  The list shows the expected and unexpected.  Index is just the order of things.  Name and NameU are identical.  ID...what's up with that???
3) change the names of the pages, but keep the order.  Run macro.  This is the special case, happens only first time.  Name and NameU update identically.  Nothing else changes.
4) change names a 2nd time.  Run macro.  Name updates, but NameU keeps its value.  In fact, NameU will remain at this value unless code is used to specifically modify it.
5) change the page order.  Run macro.  Name, NameU, and ID track with each other.  Indexing stays unchanged.  That is, Index 1 refers to whoever is on first.  Thus, the "index" of a page will update depending upon where it is in the order.

Results of each macro run have been copied and pasted following the code.

A similar analysis for shapes could be done with update to the macro.

HTH
Wapperdude

Sub ReNamePg()
'Simple macro that shows relationship for Page: Name, NameU, Index, and ID

    Dim vsoPg As Page
    Debug.Print ""
    Debug.Print "Revised Names, New Order:"     'Manually change this for desired section title
    Debug.Print "Name", "NameU", "Index", "ID"
    For Each vsoPg In ActiveDocument.Pages
        Debug.Print vsoPg.Name, vsoPg.NameU, vsoPg.Index, vsoPg.ID
    Next
End Sub

Quote
Original Names, Order:
Name          NameU         Index         ID
Page-1        Page-1         1             0
Page-2        Page-2         2             4
Page-3        Page-3         3             5
Page-4        Page-4         4             6

New Names, Original Order:
Name          NameU         Index         ID
One           One            1             0
Two           Two            2             4
Three         Three          3             5
Four          Four           4             6

Revised Names, Original Order:
Name          NameU         Index         ID
Pg1           One            1             0
Pg2           Two            2             4
Pg3           Three          3             5
Pg4           Four           4             6


Revised Names, New Order:
Name          NameU         Index         ID
Pg2           Two            1             4
Pg1           One            2             0
Pg4           Four           3             6
Pg3           Three          4             5
Title: Re: Page / Shape: Name vs NameU vs Index vs ID
Post by: alkali on July 02, 2018, 08:13:05 AM
This topic seems that it's only confusing the people. I don't realy see any advantage of this behavior.
Why isn't it easily possible to show at least both names (Name and NameU) in the Shape Sheet.
Or make it even editable.

Title: Re: Page / Shape: Name vs NameU vs Index vs ID
Post by: AndyW on July 02, 2018, 09:48:53 AM
This is done for locale support which is especially relevant to the Visio internal cells and names. Where the Name may have the locale version but the NameU (universal) will have the English (well American) name.