Get PageName based on PageNumber

Started by doone, May 11, 2018, 06:31:50 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

doone

Hello Everyone,

I have searched and found many solutions for getting information from another page in a drawing.  However, in all of the solutions, it looks like you need to have the page name in order to reference another page via a shapesheet.  How can you find information on another page if you only know the page number?  The reason I ask is because the page names (the tabs at the bottom of the screen) can get changed by the users.

Kind Regards,
Lorna

wapperdude

NameU ought to solve the problem.  Users can set Name, i.e., the local name, but not the universal name.

https://msdn.microsoft.com/en-us/vba/visio-vba/articles/page-nameu-property-visio

Wapperdude

Visio 2019 Pro

doone

Hi Wapperdude,

Thank you for relying so quickly.  I have used .NameU before in vba, but not in the shapesheet.  I'm trying to use something like ="Pages[xxx]!ThePage!Prop.MyProp" in a user-defined cell to get MyProp on page 5.  I hope this makes sense.

Kind Regards,
Lorna

doone

Hi Wapperdude,

I think I have a workaround using vba (I was hoping not to  :().  Anyway, using a combination of vba and John's suggestion from this post http://visguy.com/vgforum/index.php?topic=6619.msg27480#msg27480 I can get to the Prop.MyProp on a specific page.  I set the User.CoercedText = "Pages[Page-"&Prop.Sheet_No&"]!ThePage!Prop.MyProp".  Normally this would work fine until a user changes the page names.  So, to ensure that I can reference each page by it's number the following vba code will change the NameU back to the default naming by using the page Index (Page-1, Page-2...).

    For Each vsoPage In ActiveDocument.Pages
        i = vsoPage.Index
        If ActiveDocument.Pages(i).Background = False Then
            vsoPage.NameU = "Page-" & vsoPage.Index
        End If
    Next


I hope this can help others that are struggling with the same issue and if anyone has a better idea, I welcome the input.

Kind Regards,
Lorna

wapperdude

Ooops.  Misunderstood.  Didn't realize you wanted shapesheet solution.

Adding a specific cell, either a prop.xyz or even user.xyz is more controllable and predictable...or both.  Looks like you have a reasonable solution.

Wapperdude.
Visio 2019 Pro

Nikolay

Isn't page number even less reliable than page name? User can reorder pages quite easily (just drag the page tab to the left or to the right)

Paul Herber

If a page gets renamed then any links to the page get adjusted with the new name.
Electronic and Electrical engineering, business and software stencils for Visio -

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

doone

So, if a user reorders the pages by dragging the tabs, doesn't the index update?  I thought that the index would always give you the order in which the pages are arranged.

wapperdude

Visio 2019 Pro

doone

Excellent write-up Wapperdude.  Now I understand.  Thank you!!!

wapperdude

Visio 2019 Pro