cancel
Showing results for 
Search instead for 
Did you mean: 

Is there an event which triggers after the data has been loaded?

Former Member
0 Kudos

Hello,

i've been searching for an event which triggers after the data are loaded, but i coud not find anything.

Thanks for all replies in advance,

Kim

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Kim,

You can make use of the "AfterRedisplay" CallBack event. Analysis for Excel has a number of events that can be registered which allows your code to be executed at the appropriate time.

Copy the code below into "ThisWorkbook" and your custom code in a public sub which is titled "Callback_AfterRedisplay".

Public Function SetAOAddinActive() As Boolean

'Awesome piece of code taken

'from: http://scn.sap.com/people/olaf.fischer/blog/2011/07/26/analysis-office-11--using-the-vba-apis--hints...

    Dim addin As COMAddIn

    SetAOAddinActive = False

    For Each addin In Application.COMAddIns

      If addin.progID = "SBOP.AdvancedAnalysis.Addin.1" Then

        If addin.Connect = False Then addin.Connect = True

        SetAOAddinActive = True

      End If

    Next

End Function

"

Sample code:

Public Sub Workbook_SAP_Initialize()

' register callbacks

    Call Application.Run("SAPExecuteCommand", "RegisterCallback", "AfterRedisplay", "Callback_AfterRedisplay")

  

'Call Application.Run("SAPExecuteCommand", "RegisterCallback", "BeforePlanDataSave", "Callback_BeforePlanDataSave")

'Call Application.Run("SAPExecuteCommand", "RegisterCallback", "BeforePlanDataReset", "Callback_BeforePlanDataReset")

End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)

    Call Application.Run("SAPExecuteCommand", "UnregisterCallback", "AfterRedisplay")

End Sub

Private Sub Workbook_Open()

   

    Dim sRunMacroMsg As String

    Dim sRunMacroMsgStyle As String

    Dim sRunMacroMsgTitle As String

    Dim sSheets_To_Highlight(1 To 4) As String

   

    Dim iResponse As Integer

 

    sRunMacroMsg = "Unable to load the Analysis for Office plugin." & vbNewLine & vbNewLine & "You will not be able to use the Group Periods feature." & vbNewLine & vbNewLine _

               & "           - You should log a call with the Helpdesk to have it installed -         "

    sRunMacroMsgStyle = vbExclamation

    sRunMacroMsgTitle = "Missing Advanced Analysis for Office plugin"

   

'Ensure that the AA4E code is loaded

    If Not SetAOAddinActive Then

        iResponse = MsgBox(sRunMacroMsg, sRunMacroMsgStyle, sRunMacroMsgTitle)

    End If

     

End Sub

Public Function SetAOAddinActive() As Boolean

'Awesome piece of code taken

'from: http://scn.sap.com/people/olaf.fischer/blog/2011/07/26/analysis-office-11--using-the-vba-apis--hints...

    Dim addin As COMAddIn

    SetAOAddinActive = False

    For Each addin In Application.COMAddIns

      If addin.progID = "SBOP.AdvancedAnalysis.Addin.1" Then

        If addin.Connect = False Then addin.Connect = True

        SetAOAddinActive = True

      End If

    Next

End Function

I use the script below in an Excel module:

Public Sub Callback_AfterRedisplay()

     'Custom code here    

End Sub

Answers (0)