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

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

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: 197 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1057KB.
Tokens: post-login.
Cache hits: 13: 0.00164s for 26,764 bytes (show)
Cache misses: 2: (show)
Queries used: 15.

[Show Queries]