Author Topic: Page number in page names?  (Read 779 times)

0 Members and 1 Guest are viewing this topic.

LishNOMO

  • Newbie
  • *
  • Posts: 1
Page number in page names?
« on: October 29, 2022, 07:01:26 AM »
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

  • Hero Member
  • *****
  • Posts: 1785
    • ShapeSheet™ Knowledge Base
Re: Page number in page names?
« Reply #1 on: October 29, 2022, 10:18:11 AM »
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.
Visio engine can rename only native (default) page names, like Page-x.
IMHO only custom macro can do it!

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4752
  • Ideas Visio-lized into solutions
Re: Page number in page names?
« Reply #2 on: October 29, 2022, 01:40:46 PM »
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.
Code
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