I came across a weird bug, the onAfter events are not captured in a macro if it's run from the topic context menu. See the example code below. All four event functions fire if I run the macro from the macro editor, but only the two onBefore event functions fire if I run the macro from the topic context menu. Can anyone suggest a solution or a workaround? The idea of the macro I'm writing is that it remembers some of the topic values and then tracks their changes and records them to a table in another topic.
'#Language "WWB-COM" Option Explicit Dim WithEvents m_EventBeforeObjectModified As Event ' An event that is sent out from the API Dim WithEvents m_EventAfterObjectModified As Event ' An event that is sent out from the API Dim WithEvents m_EventBeforeSelectionChanged As Event ' An event that is sent out from the API Dim WithEvents m_EventAfterSelectionChanged As Event ' An event that is sent out from the API Sub Main Set m_EventBeforeObjectModified = Events.AddDocumentEvent(MmDocumentEventFlags.mmEventFlagObjectModified, True, False, Nothing) ' this one if OK Set m_EventAfterObjectModified = Events.AddDocumentEvent(MmDocumentEventFlags.mmEventFlagObjectModified, False, True, Nothing) ' will not fire if the macro is run from the topic context menu Set m_EventBeforeSelectionChanged = Events.AddDocumentEvent(MmDocumentEventFlags.mmEventFlagObjectModified, True, False, Nothing) ' will not fire if the macro is run from the topic context menu Set m_EventAfterSelectionChanged = Events.AddDocumentEvent(MmDocumentEventFlags.mmEventFlagObjectModified, False, True, Nothing) ' will not fire if the macro is run from the topic context menu Wait 60 ' run this macro for 60 seconds Set m_EventBeforeObjectModified = Nothing Set m_EventAfterObjectModified = Nothing Set m_EventBeforeSelectionChanged = Nothing Set m_EventAfterSelectionChanged = Nothing MsgBox("complete") End Sub Sub m_EventBeforeObjectModified_Fire(ByVal i_EventFlag As Long, ByVal e_Time As MmEventTime, ByVal m_Object As Object, ByRef p_Extra As Variant) Debug.Print("m_EventBeforeObjectModified_Fire") End Sub Sub m_EventAfterObjectModified_Fire(ByVal i_EventFlag As Long, ByVal e_Time As MmEventTime, ByVal m_Object As Object, ByRef p_Extra As Variant) Debug.Print("m_EventAfterObjectModified_Fire") End Sub Sub m_EventBeforeSelectionChanged_Fire(ByVal i_EventFlag As Long, ByVal e_Time As MmEventTime, ByVal m_Object As Object, ByRef p_Extra As Variant) Debug.Print("m_EventBeforeSelectionChanged_Fire") End Sub Sub m_EventAfterSelectionChanged_Fire(ByVal i_EventFlag As Long, ByVal e_Time As MmEventTime, ByVal m_Object As Object, ByRef p_Extra As Variant) Debug.Print("m_EventAfterSelectionChanged_Fire")End Sub