Page change (switch) event ?

M

Mikhail Fishbeyn

1. I need to get event when user selects a different page of the document (by clicking the page tab control). How can I do it?

2. How can I reliably change the page tab menu? Unless I have the above event I don't know when to do it.

Thanks,
Mikhail
 
H

Hadriel

Three ways:
1) Add an event object via the eventlist.addadvise method (See SDK for info)
for the visEvtCodeWinPageTurn of Application, Windows or Window object
(depending on what events you want to trap).
2) Add an event object via the eventlist.add method for similar as (1). I
have tried this method and it fails depending on what you want it to do, but
is simpler than addadvise.
3) Trap the WindowTurnedToPage event using WithEvents (for VB/VBA). The
simplest and least flexible method. Again see the SDK or Help.

One word of caution: while one would think this is a safe event to trap, I
have seen it come before Visio event flushing is complete when the user
deletes a page. In theory you can get into trouble if you trap events and
change stuff which causes other events, if it's before visio flushes some
event queues. I have crashed visio when doing that for the
BeforeWindowPageTurn event, because that is in the middle of a flush every
time. I haven't crashed it with the methods above.
-Hadriel
p.s. changing the page tab after that should be a simple matter of setting
the ActivePage object to the one you want, if you don't like the page the
user changed to.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top