Hi, there's a lot going on here.
First a little remark regarding the
terminology. A sheet in Excel is a worksheet - a tab in the document / workbook. In Visio, a sheet refers to a shapesheet object (can be a shape or a page or a doc, etc.).
You were meaning page instead of sheet.
How to implement:
1 - lazy way:Your file must be "macro-enabled" - save it as vsdm instead of vsdx.
In the IDE, there is a ThisDocument module. By means of the dropdown lists on top of the main window you can write code for the document_pagechanged event.
2 - better way:The lazy way has in so far disadvantages as the file must be a vsdm, the code is implemented in the file instances themselves - very difficult to maintain.
Better is to move the code into a stencil (vssm) and run it from there.
I would put it in a modeless form and let it do its job as long as the form is open (and only then!).
Code for the form:Option Explicit
Private WithEvents vWin As Visio.Window
Private Sub UserForm_Initialize()
Set vWin = Application.ActiveWindow
End Sub
Private Sub vWin_WindowTurnedToPage(ByVal Window As IVWindow)
'Do your operations here
Debug.Print vWin.Page.Name
End Sub
But I wonder if you shouldn't
rethink your idea.
There should be better ways to achieve whatever you're doing.
You could for instance draw on a page and use it as background for other pages.
But it depends on what your final aim is. You may want to explain this more in detail.
HTH and Rgds,