Micro station Version : 08.05.01.25 Windows x86 (1990-2004 bently systems)
Programming Language :VBA
I'm using below code as class function in micro station v8 mvba tool.
Implements IChangeTrackEvents Private Sub IChangeTrackEvents_BeginUndoRedo(ByVal AfterUndoRedo As Element, ByVal BeforeUndoRedo As Element, ByVal Action As MsdChangeTrackAction, ByVal IsUndo As Boolean) End Sub Private Sub IChangeTrackEvents_ElementChanged(ByVal AfterChange As Element, ByVal BeforeChange As Element, ByVal Action As MsdChangeTrackAction, CantBeUndone As Boolean) 'my logic End Sub Private Sub IChangeTrackEvents_FinishUndoRedo(ByVal IsUndo As Boolean) End Sub Private Sub IChangeTrackEvents_Mark() 'my logic End Sub
i can using below command to trigger the above class function,
Dim changeTrack As clsTrackEvents Set changeTrack = New clsTrackEvents AddChangeTrackEventsHandler changeTrack
it's working but i'm not able to remove the handler function of this class even i'm using below remove handler code,
RemoveChangeTrackEventsHandler changeTrack
so kindly suggest me, how to remove this change track event handler class function once I used.
Your ChangeTrackHandler must be a global class instance. You need to declare a global pointer in a VBA module. A good place is in a UserForm ...
ChangeTrackHandler
UserForm
Private m_oTrackEvents As clsTrackEvents
Initialise the handler, probably in your UserForm initialise subroutine...
Set m_oTrackEvents = New clsTrackEvents AddChangeTrackEventsHandler m_oTrackEvents
When you've finished, destroy the global variable in your UserForm.Terminate subroutine...
UserForm.Terminate
RemoveChangeTrackEventsHandler m_oTrackEvents Set m_oTrackEvents = Nothing
The tricky part is to decide when to call RemoveChangeTrackEventsHandler. If your macro has a UserForm, then a good time to call RemoveChangeTrackEventsHandler is when that form is closed.
RemoveChangeTrackEventsHandler
Regards, Jon Summers LA Solutions
Hi Jon,
Thanks,
I'll try but the class function will process as like recursion in my logic and form is active those times and it will closed. So any possible to do that?
Abdul Latheef said:form is active those times and it will close
Make your form modeless: MyForm.Show vbModeless. Then your UserForm will survive while your macro is active, and any object reference is maintained by the form.
MyForm.Show vbModeless
Thanks Jon,
It works.