Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: doone on May 11, 2018, 06:31:50 PM

Title: Get PageName based on PageNumber
Post by: doone on May 11, 2018, 06:31:50 PM
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
Title: Re: Get PageName based on PageNumber
Post by: wapperdude on May 11, 2018, 07:49:19 PM
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 (https://msdn.microsoft.com/en-us/vba/visio-vba/articles/page-nameu-property-visio)

Wapperdude

Title: Re: Get PageName based on PageNumber
Post by: doone on May 11, 2018, 08:03:00 PM
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
Title: Re: Get PageName based on PageNumber
Post by: doone on May 11, 2018, 10:02:57 PM
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
Title: Re: Get PageName based on PageNumber
Post by: wapperdude on May 11, 2018, 11:12:09 PM
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.
Title: Re: Get PageName based on PageNumber
Post by: Nikolay on May 12, 2018, 08:17:53 AM
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)
Title: Re: Get PageName based on PageNumber
Post by: Paul Herber on May 12, 2018, 12:01:33 PM
If a page gets renamed then any links to the page get adjusted with the new name.
Title: Re: Get PageName based on PageNumber
Post by: doone on May 14, 2018, 04:29:04 PM
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.
Title: Re: Get PageName based on PageNumber
Post by: wapperdude on May 17, 2018, 07:59:17 PM
See this new topic, http://visguy.com/vgforum/index.php?topic=8417.msg36441;topicseen#msg36441 (http://visguy.com/vgforum/index.php?topic=8417.msg36441;topicseen#msg36441)

Wapperdude
Title: Re: Get PageName based on PageNumber
Post by: doone on May 17, 2018, 08:58:18 PM
Excellent write-up Wapperdude.  Now I understand.  Thank you!!!
Title: Re: Get PageName based on PageNumber
Post by: wapperdude on May 17, 2018, 10:30:11 PM
 ;)