_SelectionChanged Event

Started by MacGyver, August 28, 2012, 05:37:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MacGyver

I am having some trouble writing a macro that executes when the selection within a document changes.  Any help would be appreciated.

Private Sub object_SelectionChanged(ByVal Window As IVWindow)

I attempted using ActiveDocument as the object and placing this macro in the ThisDocument module but that didn't seem to work

http://msdn.microsoft.com/en-us/library/office/aa214134%28v=office.11%29.aspx

aledlund

well your first hint is that the value returned is a window, so the object should be a window.
(don't forget to instantiate it ' set m_visWin = application.activewindow )

Public WithEvents m_visWin As Visio.Window

Public Sub m_visWin_SelectionChanged(ByVal Window As IVWindow)
    ' do something with the event
end sub

al

MacGyver

where should i be instantiating it?

should i write a seperate macro to instantiate it after the document opens?


aledlund

Usually it's an entry in the documentopened event handler.
al

MacGyver

Perfect!! Works like a charm  ;D