News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

Reference page by ID instead of name

Started by dmac101, October 21, 2021, 01:34:10 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dmac101

Hi All, Just wondering if there is a way to reference pages by id or page number rather than by page name.
I have created shape data for each page, linked to the title block and was trying to access this from the main index page
Currently I am inserting a field to a table using the following formula.
=Pages[Site Layout]!Sheet.81!Prop.Title.
I would prefer to reference the page by ID as this will allow for changes in page names.
Is this possible?

Surrogate

#1
https://docs.microsoft.com/en-us/office/client-developer/visio/about-cell-references
There is article about references, i mean you can't use number for page identify

After renaming of page local (name as user can see) and universal (name as Visio engine know) page names are different !



English interfaceRussian interface

wapperdude

Here's small macro to reset the local and universal page names so that they match. 

Sub fixPgNames()
'Call this sub if page names are creating an error and need fixing.
    Set pgsObj = ActiveDocument.Pages
    For Each pgObj In pgsObj
        pgObj.Name = pgObj.Name
        pgObj.NameU = pgObj.Name
    Next
End Sub
Visio 2019 Pro

wapperdude

To supplement the reference provided by Surrogate, this reference, "Elements of Visio Formulas", provides bit more detail plus examples.
https://docs.microsoft.com/en-us/previous-versions/office/developer/office-xp/aa200961(v=office.10)
Visio 2019 Pro

dmac101

Thanks Guys,
Looks like it is not going to be a simple solution to achieve the end goal which is to get page names and drawing id's which i have stored in a shape on each page and create an index page.

wapperdude

A bit of work, yes.  A method could be
1) arrange the pages as desired
2) run the macro to re-sync the page na.rd as needed
3) to create index, then,
    A) loop thru document page collection, one page at atime
          I) get page name
         II) get page number
        III) store in an array
    B) for each page, loop thru shape collection, putting desired info in an array
    C) after all pages and shapes have been identified and info collected, pull info out of the array(s) and place on your index page.

Yes. It will take a bit of coding to do this.  Search the forum for Table of Contents.  There are a variety of schemes that have been developed.  One might be adaptable for your task... saving you much work.
Visio 2019 Pro

dmac101

Thanks wrapperdude, I will search through forum for TOC and read through these posts.

Surrogate

Quote from: wapperdude on October 21, 2021, 11:44:21 PM
Search the forum for Table of Contents.  There are a variety of schemes that have been developed.  One might be adaptable for your task... saving you much work.
Mr. Dude you mean this TOC ?
http://visguy.com/vgforum/index.php?topic=8730

I usually have advice like this
1. don't abuse page renaming
2. when adding a page to a document, make it named at once!
---
I have solutiom which based on ShapeSheet, but I can't even explain it in Russian   ???

wapperdude

I didn't have any particular link in mind.  I just remembered seeing several approaches.  Here are some additional...

http://visguy.com/vgforum/index.php?topic=8298.msg35873#msg35873
http://visguy.com/vgforum/index.php?topic=6250.0
http://visguy.com/vgforum/index.php?topic=8387.msg36295#msg36295
http://visguy.com/vgforum/index.php?topic=7393.msg31126#msg31126

@Surrogate:  shapesheet solution!?!   :o. I can believe it's hard to explain.  That required a lot of creative/resourceful thinking!!!
Visio 2019 Pro

Surrogate

#9
Quote from: wapperdude on October 22, 2021, 05:34:38 AM@Surrogate:  shapesheet solution!?!   :o. I can believe it's hard to explain.  That required a lot of creative/resourceful thinking!!!
Of course there is a lot of limitations:
1. User can rename page not more that one time;
2. The first figure to be dropped on the page is the text from which is to be displayed in the TOC.
Epic video just for lulz please watch it with English sub-titles

UPD few days ago i find this 3rd party macro for create TOC

dmac101

Thanks all, The TOC was only one aspect of what i was trying to achieve and i am really struggling due to my programming knowledge. I have started to look at this from a completely different angle now.
Goals:-

  • add name of each page to specific text field (one for each page) to cover page
  • add drawing ID for each page in text field adjacent to page name on cover page
  • link project name and project id from cover page to specific field on each page
  • link cover page to external data
I was exploring the idea of using the document User-defined cells to store the data for project name and ID, then link each page to it. This seems to work but I am not sure if there was a way to link the document user cell to a shape data field so that when i link to external it updates the doc user field which in turn then updates all pages. If this is feasible I would then look at creating document user field for p1name, p2name, etc and push from each page.
So far i have only been able to access the document user fields through drawing explorer shapesheet. Can i reference specific pages and shapes from the document shapesheet or can i push to document user cells from any shapes shapesheet?


dmac101

Alternatively can I reference shape data directly from a separate page. ie something similar to the below ?

=Pages[CoverPage]!sheet.1659!Prop._VisDM_Project_ID

dmac101

Hi All, I have managed to achieve this using =SETF(GetRef(TheDoc!User.Project_Name),Prop._VisDM_Project_Name).
Still working on it but now moving forwards.

wapperdude

Proposed approach ought to work.  The question becomes a matter of minutes effort.  For a document with only a handful of pages, this wouldn't be too bad.  If the number of pages is quite high and/or vary over time, then automation (coding) is probably a better solution.  A bit more time upfront, but more accommodating to page count changes.
Visio 2019 Pro

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 425 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1217KB.
Tokens: post-login.
Cache hits: 13: 0.00128s for 26,767 bytes (show)
Cache misses: 2: (show)
Queries used: 16.

[Show Queries]