Update ActivePage when shifting between fans/pages

Started by smelvadj, April 05, 2019, 07:43:55 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

smelvadj

All my event based code depends on a m_page variable which is set AS the activePage. Yet, i need a Way to set my m_page to the real active page where i do my changes before the event based code is activated. Hos can i update the ActivePage to always be the current page ??

Yacine

m_page won't be updated when you change the page, but activepage will.
So either you reassing m_page to activepage in each piece of your code,
or you catch the event page changed at doc level and do the reassignement there - at one central place.
Yacine

smelvadj

Hi, Think you for the reply.

I have tried the pageChanged event, but this only fires if i change the name of the page.

I an looking for another event which is triggered when i shift page, because alle my other code are fired by m_page events and is therefore dependent on that m_page is equal to ActivePage.

OldSchool1948

This will update the m_vsoPage variable after you change pages

Private Sub m_visWins_WindowTurnedToPage( _
                ByVal visWin As IVWindow)

    '// visWin is the window, as it is AFTER
    '// the page has been turned.
       
    Set m_vsoPage = Visio.ActivePage

End Sub


This will update the m_vsoPage variable before you change pages

Private Sub m_visWins_BeforeWindowPageTurn( _
                ByVal visWin As IVWindow)

    '// Note: visWin.Page holds the page that
    '// visWin shows BEFORE the page is turned!

    Set m_vsoPage = Visio.ActivePage
   
End Sub


I use this code to setup and close things out

Option Base 1
Option Explicit

Private WithEvents m_vsoApp As Visio.Application
Private WithEvents m_visWins As Visio.Windows
Private WithEvents m_vsoPage As Visio.Page


Private Sub Document_RunModeEntered( _
                ByVal doc As IVDocument)
                   
    '// Initialize Global Variables
    Set m_vsoApp = ThisDocument.Application
    Set m_visWins = Visio.Application.Windows
    Set m_vsoPage = Visio.ActivePage

End Sub


Private Sub Document_BeforeDocumentClose( _
                ByVal doc As IVDocument)
       
    Set m_vsoApp = Nothing
    Set m_visWins = Nothing
    Set m_vsoPage = Nothing

End Sub