Author Topic: Get PageName based on PageNumber  (Read 193 times)

0 Members and 1 Guest are viewing this topic.

doone

  • Jr. Member
  • **
  • Posts: 11
Get PageName based on PageNumber
« on: May 11, 2018, 01: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

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3128
  • Ideas Visio-lized into solutions
Re: Get PageName based on PageNumber
« Reply #1 on: May 11, 2018, 02: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

Wapperdude

Visio 2007 Std

doone

  • Jr. Member
  • **
  • Posts: 11
Re: Get PageName based on PageNumber
« Reply #2 on: May 11, 2018, 03: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

doone

  • Jr. Member
  • **
  • Posts: 11
Re: Get PageName based on PageNumber
« Reply #3 on: May 11, 2018, 05: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...).

Code: [Select]
    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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3128
  • Ideas Visio-lized into solutions
Re: Get PageName based on PageNumber
« Reply #4 on: May 11, 2018, 06: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.
Visio 2007 Std

Nikolay

  • Hero Member
  • *****
  • Posts: 710
    • UnmanagedVisio
Re: Get PageName based on PageNumber
« Reply #5 on: May 12, 2018, 03: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)

Paul Herber

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2580
    • Paul Herber's website
Re: Get PageName based on PageNumber
« Reply #6 on: May 12, 2018, 07:01:33 AM »
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 and applications for Visio -

http://www.paulherber.co.uk/

doone

  • Jr. Member
  • **
  • Posts: 11
Re: Get PageName based on PageNumber
« Reply #7 on: May 14, 2018, 11:29:04 AM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3128
  • Ideas Visio-lized into solutions
Re: Get PageName based on PageNumber
« Reply #8 on: May 17, 2018, 02:59:17 PM »
Visio 2007 Std

doone

  • Jr. Member
  • **
  • Posts: 11
Re: Get PageName based on PageNumber
« Reply #9 on: May 17, 2018, 03:58:18 PM »
Excellent write-up Wapperdude.  Now I understand.  Thank you!!!

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3128
  • Ideas Visio-lized into solutions
Re: Get PageName based on PageNumber
« Reply #10 on: May 17, 2018, 05:30:11 PM »
 ;)
Visio 2007 Std