Visio Guy

Visio Discussions => Programming & Code => Topic started by: MacGyver on August 28, 2012, 05:37:30 PM

Title: _SelectionChanged Event
Post by: MacGyver on August 28, 2012, 05:37:30 PM
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 (http://msdn.microsoft.com/en-us/library/office/aa214134%28v=office.11%29.aspx)
Title: Re: _SelectionChanged Event
Post by: aledlund on August 28, 2012, 06:23:32 PM
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
Title: Re: _SelectionChanged Event
Post by: MacGyver on August 28, 2012, 07:47:00 PM
where should i be instantiating it?

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

Title: Re: _SelectionChanged Event
Post by: aledlund on August 28, 2012, 09:37:35 PM
Usually it's an entry in the documentopened event handler.
al
Title: Re: _SelectionChanged Event
Post by: MacGyver on August 29, 2012, 03:24:16 PM
Perfect!! Works like a charm  ;D