cancel
Showing results for 
Search instead for 
Did you mean: 

After_ContextChange not working

0 Kudos

Hi,

I have a workbook with the following VBA code.

Function AFTER_WORKBOOK_OPEN()
    MsgBox "On Open"
End Function
    
Function BEFORE_CONTEXTCHANGE()
    MsgBox "Before Context Change"
End Function

Function AFTER_CONTEXTCHANGE()
    MsgBox "After Context Change"
End Function

and the sheet has a button with the following

=@EPMContextMember(,"DEPARTMENT")

When I change the context, the Before_ContextChange message displays but the After_ContextChange message does not display. If I remove the After_Workbook_Open, the After_ContextChange message displays fine. Can someone offer a suggestion as to the cause?

Thanks

Cliff

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member186338
Active Contributor
0 Kudos

Don't use MsgBox if you want to look on event sequence,

Use log with the shape TextBox:

Function AFTER_WORKBOOK_OPEN()
    ThisWorkbook.Worksheets("Sheet1").Shapes("TextBox 1").TextFrame.Characters.Text = _
    ThisWorkbook.Worksheets("Sheet1").Shapes("TextBox 1").TextFrame.Characters.Text & "On Open" & vbCrLf
End Function
    
Function BEFORE_CONTEXTCHANGE()
    ThisWorkbook.Worksheets("Sheet1").Shapes("TextBox 1").TextFrame.Characters.Text = _
    ThisWorkbook.Worksheets("Sheet1").Shapes("TextBox 1").TextFrame.Characters.Text & "Before Context Change" & vbCrLf
End Function

Function AFTER_CONTEXTCHANGE()
    ThisWorkbook.Worksheets("Sheet1").Shapes("TextBox 1").TextFrame.Characters.Text = _
    ThisWorkbook.Worksheets("Sheet1").Shapes("TextBox 1").TextFrame.Characters.Text & "After Context Change" & vbCrLf
End Function

TextBox 1 - shape inserted in Sheet1

Result (in TextBox 1):

Before Context Change
After Context Change

when I change context using:

=EPMContextMember(,"TIME")

P.S. By the way, if you change context directly, selecting member in EPM Context - then ONLY "After Context Change" event is generated.