Page number in page names?

Started by LishNOMO, October 29, 2022, 12:01:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LishNOMO

How to add page numbers to pages to is well documented, for example, here: http://visguy.com/vgforum/index.php?topic=1286.0.

But is there a way to add page numbers to the page name?  I'm referring to the page name in the tab below the page, as shown here: https://support.microsoft.com/en-us/office/reorder-and-rename-pages-97659151-3564-4406-bc4c-f60aed190aa8.

I'm working with documents that are labeled Fig. 1, Fig. 2, etc. both in the page and in the page name tab.  Re-ordering/inserting/deleting pages updates the page number field, but not the page name.

Is there a way to do this?

Surrogate

Quote from: LishNOMO on October 29, 2022, 12:01:26 PMI'm working with documents that are labeled Fig. 1, Fig. 2, etc. both in the page and in the page name tab.  Re-ordering/inserting/deleting pages updates the page number field, but not the page name.
Visio engine can rename only native (default) page names, like Page-x.
IMHO only custom macro can do it!

wapperdude

Surrogate is correct, changing page tab names takes custom macro.  Below is very simple example.  It takes the name of the current active page and changes it to "Fig #" where # is the index of the current page.  If you want to make create consecutive numbering, say, Fig 1, Fig 2, ..., that takes more coding and planning to determine what number to add to the sequence. 

Somehow, you need to loop thru all pages searching for those that have "Fig" and determine the next number in the sequence to use for name.

Sub ChgPgName()
    Dim vPg As Visio.Page
   
    Set vPg = ActiveDocument.Pages.Item(1)
    vPg.Name = "Fig " & vPg.Index
   
End Sub


If you want to add a new page, use this:          Set vPg = ActiveDocument.Pages.Add

HTH

Visio 2019 Pro