I have a single userform with 3 "top-level" pages (using the multipage functionality) and then four nested pages each within two of the top-level pages.
Screenshot of Nested Multipage Userform

In this example, the page captions and names are the same. Therefore, the page with the caption of Page4 is also named Page4. I found code online that is supposed to return the page index when the page name is passed to it:
Function fMpIndex(ByVal PageName As String)
Dim PageCounter As Long
With MultiPage1
For PageCounter = 0 To .Pages.Count - 1
If .Pages(PageCounter).Name = PageName Then fMpIndex = PageCounter: Exit Function
Next PageCounter
End With
fMpIndex = -1
End Function
This works for the top-level pages, however, when I try something like:
MsgBox ("This page's index is " & fMpIndex("Page5"))
for any of the nested pages (in this example, both pages 4 & 5), then this method returns a value of -1, indicating that the page does not exist. Is this a scope issue? Does the code above only search for the top-level pages and not the nested pages?
What is the safest, most reliable way to programmatically reference a specific page by either name or caption or both? I assume it would be something like:
which userform.which page strip.which page.name("Page5")
In this example, I only have one userform, but what if I had two userforms? Also, in the above example, I am assuming that one must specify which of the two page strips are being referenced.
Ideally, I want a way to use an absolute reference to each page in the userform regardless of whether it is a top-level page or a nested page.