on 08-25-2014 1:19 PM
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
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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.