Author Topic: Page / Shape: Name vs NameU vs Index vs ID  (Read 34 times)

0 Members and 1 Guest are viewing this topic.

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3128
  • Ideas Visio-lized into solutions
Page / Shape: Name vs NameU vs Index vs ID
« on: May 17, 2018, 02: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/
Shapes:  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

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
Code: [Select]
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
« Last Edit: May 17, 2018, 02:56:55 PM by wapperdude »
Visio 2007 Std