Author Topic: Jump to the first page when its name is not known  (Read 958 times)

0 Members and 1 Guest are viewing this topic.

Hey Ken

  • Full Member
  • ***
  • Posts: 213
  • Just This Guy
    • The Pennsylvania Project, with Ken Krawchuk
Jump to the first page when its name is not known
« on: April 11, 2018, 12:12:16 PM »
Folks:

    Quick question: I want to use shapesheet functionality to jump to the first page, either as a double click or right-click action.  The complication is that I don’t necessarily know the name of the first page.  It’s trivial to do in VBA...

Code

ActiveWindow.Page = ActiveDocument.Pages.ItemU(1)


   ...but how do I do it on the shapesheet?  GOTOPAGE requires that you know the name.  Ditto for Pages[1]!ThePage!User.PageName.  Further complicating things, I want to do it from a background page, so I can't use a hyperlink--not that it would work either.

    Thanks in advance,

    - Ken

Ken V. Krawchuk
'caster

The Pennsylvania Project
Radio Podcast

10 to 11 AM Saturdays on WWDB 860 AM in Philadelphia
7 to 8 AM Mondays on KUR 1670 AM in Kutztown
On demand at http://PennsylvaniaProject.com

Hey Ken

  • Full Member
  • ***
  • Posts: 213
  • Just This Guy
    • The Pennsylvania Project, with Ken Krawchuk
Re: Jump to the first page when its name is not known
« Reply #1 on: April 19, 2018, 10:45:45 AM »

   Hmmm... 42 views, 0 replies.  I guess it’s not possible.  Time for Plan B (as in VBA).

   - Ken
Ken V. Krawchuk
'caster

The Pennsylvania Project
Radio Podcast

10 to 11 AM Saturdays on WWDB 860 AM in Philadelphia
7 to 8 AM Mondays on KUR 1670 AM in Kutztown
On demand at http://PennsylvaniaProject.com

Yacine

  • Hero Member
  • *****
  • Posts: 2670
Re: Jump to the first page when its name is not known
« Reply #2 on: April 20, 2018, 12:30:25 AM »
Right, I spent over an hour on it  without success.
Yacine

metuemre

  • Full Member
  • ***
  • Posts: 172
Re: Jump to the first page when its name is not known
« Reply #3 on: April 20, 2018, 01:57:49 AM »
I got a partial solution that requires to know the name of the first page only once. Please check the attached file.

Assuming that first page is named as "Page-1" at the beginning. The formula "=Pages[Page-1]!ThePage!PAGENAME()" returns the name of "Page-1". The beauty of this formula is that it updates itself if "Page-1" is renamed to something else. So the formula  "=GOTOPAGE(Pages[Page-1]!ThePage!PAGENAME())" inside EventDblClick cell will always take you to the first page.

Regards,

Croc

  • Full Member
  • ***
  • Posts: 220
    • Visioport
Re: Jump to the first page when its name is not known
« Reply #4 on: April 20, 2018, 05:27:32 AM »
There is one more thought ...
If you force all pages to transfer their names to a document, then perhaps this will help solve the problem.
Look at the picture.
Several User Cells are created in the document.
On each page there is a shape that transfers the value of PageName to the user.Row_ + i cell of the document, where i = PageNumber. That is, it creates a table of contents for the document.

Hey Ken

  • Full Member
  • ***
  • Posts: 213
  • Just This Guy
    • The Pennsylvania Project, with Ken Krawchuk
Re: Jump to the first page when its name is not known
« Reply #5 on: April 20, 2018, 06:49:58 AM »

Metuemre:

   That did it!  Your solution fit the use case perfectly. 

   You see, I distribute a template file with several pages, and some of those pages have a link to jump back to the first page.  My justified concern is that people will change the name of the first page (with me being one of the most egregious offenders) and break things.  GOTOPAGE(Page-1) breaks.  But your solution never breaks, even if you move things around or create a new first page.  Visio remembers the page by some internal name apparently not available to us mere humans.  Nice.


 Croc:

   An interesting approach, but not nearly as simple.  But at least it has the decency to be understandable.  On the other hand, Metuemre’s solution could be maddening when someone sees it jumps to a page that does not exist.


Yacine:

   Thanks muchly for the attempt, as always.


All:

   Until next time,

   - Ken

Ken V. Krawchuk
'caster

The Pennsylvania Project
Radio Podcast

10 to 11 AM Saturdays on WWDB 860 AM in Philadelphia
7 to 8 AM Mondays on KUR 1670 AM in Kutztown
On demand at http://PennsylvaniaProject.com

Hey Ken

  • Full Member
  • ***
  • Posts: 213
  • Just This Guy
    • The Pennsylvania Project, with Ken Krawchuk
Re: Jump to the first page when its name is not known
« Reply #6 on: March 25, 2019, 07:54:01 AM »

   But your solution never breaks, even if you move things around or create a new first page.  Visio remembers the page by some internal name apparently not available to us mere humans.  Nice.


   Famous last words, as they say, because FYI the solution does break under certain circumstances.  For some odd reason, if you put the formula "=Pages[Page-1]!ThePage!PAGENAME()" into the document shapesheet, Visio blows up with a 318 error whenever you press ctrl-C (using 2013 professional).  No idea why.  Fortunately, Surrogate wrote a short macro to prevent the errors from occurring, albeit at some cost.  But having a solution is better than not having one, and I'm not surprised to find the solution here on this forum -- written five years ago!

   - Ken
Ken V. Krawchuk
'caster

The Pennsylvania Project
Radio Podcast

10 to 11 AM Saturdays on WWDB 860 AM in Philadelphia
7 to 8 AM Mondays on KUR 1670 AM in Kutztown
On demand at http://PennsylvaniaProject.com