Visio Guy

Visio Discussions => Shapes & Templates => Topic started by: novski on April 08, 2014, 01:40:33 PM

Title: page name in different page
Post by: novski on April 08, 2014, 01:40:33 PM
Hi
I mangaged to get the pagename of my active page in to a shape.
But, how can i get the pagename of a page that is not active?
Title: Re: page name in different page
Post by: Jumpy on April 08, 2014, 03:35:42 PM
Pages[Page-3].Pagename()
Title: Re: page name in different page
Post by: novski on April 15, 2014, 02:53:24 PM
hi
I tried to get that working but unfortunately i can't make it.
Are you shure thats the right code?

Title: Re: page name in different page
Post by: wapperdude on April 15, 2014, 05:22:51 PM
The pagename() is pretty rude.  It works well in title blocks, and on the active page.  To make it reference a non-active page, is almost more work than just entering the name manually.  But, as far as I can tell, you need to do the following:

Background:  let's say my non-active page is (was) page-2, but I renamed it to MyPage in the page tab.

Go to MyPage and open its shapesheet.
>  Insert User-Defined section
>  Rename the row to PgName
>  in the Value cell, enter pagename()

Close shapesheet, and go to desired page.  Select shape you want to show the page name, MyPage.

Insert>Field>Custom Formula:  Pages[MyPage]!ThePage!User.PgName

The trick is that every page would need, in this case, a User-Defined section, with a row named PgName, and a Value formula "pagename()" no quotes.  Then, in the shape on the active page, you must specify which non-active page, and call the User.PgName entry.

I think there may be some posts to do this via code on this site, try searching for pagename().

HTH
Wapperdude.

Title: Re: page name in different page
Post by: novski on April 17, 2014, 08:06:07 AM
Hi
Thanks for that. I found some help in a bvisiual post. I managed to get the
http://blogs.msdn.com/b/visio/archive/2006/06/27/647570.aspx?CommentPosted=true#commentmessage (http://blogs.msdn.com/b/visio/archive/2006/06/27/647570.aspx?CommentPosted=true#commentmessage)
OffPageReference working with link but the Text doesn't show the Linked page name.
Instead it shows the page name it is sitting on. On the last Picture of this post
http://blog.bvisual.net/2011/09/02/page-grids-and-off-page-references/ (http://blog.bvisual.net/2011/09/02/page-grids-and-off-page-references/)
i see that his shape shows the name of the page it refers to...

thats exactly what i whant to do. but how?

best regards
novski
Title: Re: page name in different page
Post by: wapperdude on April 18, 2014, 12:58:07 AM
A little confused here...are you interested in using the offpage connector shape?

You need to do a few steps that are indicated in the referenced post...

1.)  Drop an offpage connector onto your page and delete it.  This creates a master in the document stencil.  Note, this is only available in the current document.  After editing, you could save the modified mastershape to a custom stencil, and then it would be available for other documents.

2.)  Then edit this master to Match name on drop and to sync the text as described.

3.)  Now, edit the master shape's shapesheet:
      a.)  Add User Defined section
      b.)  Add new row and give it a catchy name, or not, like user.EqPageName.
      c.)  In the value cell, enter pagename().

      d.)  Add Hyperlink section
      e.)  Change row name to Hyperlink.OffPageConnector.  This is critical, because when you create an offpage reference, the code will generate this row.  But, this row must pre-exist in order to make a valid field insert below.

4.)  Go back to the master shape drawing page, and then Insert>Field>Custom. Enter the following formula, using whatever name you used in 3b above:  User.EqPageName&CHAR(10)&Hyperlink.OffPageConnector.SubAddress

Close the shapesheet, close and save the master shape drawing page. 

Explanation: 
The formula will show two entries:  1st, the current page and 2nd the linked pagename.  if you don't want the current page name, just delete the User.EqPageName&char(10)&, keeping only the hyperlink info.

This only works because of the built-in functionality of the offpage connector.  Hopefully, I have all of the steps, and have them correctly indicated.

HTH
Wapperdude
Title: Re: page name in different page
Post by: wapperdude on April 18, 2014, 04:08:05 PM
Making the hyperlink trick a little more general, to grab a non-active page name, you could do the following:

Place a shape on the active page.  Create a hyperlink.  Go to Insert, Fields, custom and enter this formula:  Hyperlink.Row_1.SubAddress.  This doesn't have any of the add-on code that the off-page reference shape has, but, if all you need is the off-page name (and the "bonus" of hyperlinking), than this should work fine.

If you want your shape to show more pages, you just add more hyperlinks.  Each new hyperlink inserts a new line in the hyperlink section.  You can then expand the custom field formula to something like:  Hyperlink.Row_1.SubAddress&CHAR(10)&Hyperlink.Row_2.SubAddress

This has the benefit that if you right click on the shape, the pop-up context window allows you to select which page you'd like to navigate to.

HTH
Wapperdude
Title: Re: page name in different page
Post by: Yacine on April 18, 2014, 08:52:56 PM
Nice!
Title: Re: page name in different page
Post by: novski on April 22, 2014, 08:07:39 AM
Thanks a lot! That worked!
Novski