Skip to Content

Callback_AfterRedisplay not working in Analysis for Office Workbook

Hi everyone, I have created an Analysis for Office Report which contains different datasources from 2 InfoProviders (CRM activities and opportunities). Unfortunately in the activity InfoProvider the Characterics are called


In the Opportunity InfoProvider they are called


So when filtering the report to a certain Sales Group or Sales Office I would have to add 2 filters. To avoid this I would like to set one filter via VBA. Under ThisWorkbook I have registered the callbacks

Public Sub Workbook_SAP_Initialize()

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

End Sub

In Module1 I added the following code to read the values from the activity filter and set it for the opportunity filter

Sub FilterSalesGroup()

Application.ScreenUpdating = False


'Select the Variable from Activity Filter

Dim lResult As Long

Dim SlsGrp As String

SlsGrp = Range("C6").Value

Dim SlsOff As String

SlsOff = Range("C5").Value

'Set the SlsGroup variable as filter for the OPP Data Source

lResult = Application.Run("SAPSetFilter", "DS_3", "0BP_ACTIVIT__0SALES_GRP", SlsGrp, "INPUT_STRING")

lResult = Application.Run("SAPSetFilter", "DS_1", "0BP_ACTIVIT__0SALES_GRP", SlsGrp, "INPUT_STRING")

'Set the SlsOff variable as filter for the OPP Data Source

lResult = Application.Run("SAPSetFilter", "DS_3", "0BP_ACTIVIT__0SALES_OFF", SlsOff, "INPUT_STRING")

lResult = Application.Run("SAPSetFilter", "DS_1", "0BP_ACTIVIT__0SALES_OFF", SlsOff, "INPUT_STRING")

Application.ScreenUpdating = True

End Sub

Public Sub Callback_AfterRedisplay()

Call FilterSalesGroup

End Sub

So each time the Sales Group or Sales Office Filter for the Opportunity Data source are set, the Macro should set the same filters for the Opportunity Datasources DS_1 & DS_3.

If I start the Macro FilterSalesGroup manually or from a button within Excel, it works fine. But the Callback_AfterRedisplay method is not working in this workbook, while I use the same framework in another report. Of course we will change the InfoProviders, but I would like to use the VBA procedure as a workaround for the time being.

Is anyone facing the same issues? Any ideas are welcome

Thanks Stefan

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • 3 days ago

    Theoretically, your code should work. I tried running something similar by calling a different macro in the Callback_AfterRedisplay (version 2.7). I'm guessing this has to do with the activity of your FilterSalesGroup macro. To test, instead of calling the FilterSalesGroup macro, have it call a simple macro that just says msgbox "This worked". I'm guessing it will run correctly.

    I may be wrong, but wouldn't your code create an infinite loop because of your AfterRedDisplay has SAPSetFilter query within it? If this actually worked, wouldn't it keep triggering the AfterRedisplay procedure...? Again, if you commented out these lines of code, perhaps it works.

    As a workaround, perhaps have users refresh by pressing a specific button that calls each macro (including refresh) from start to finish?

    Curious if you (or anyone) determines if that infinite loops is the issue.

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 11 at 09:51 AM


    i tried your code on my machine and ran into the same problem, the "normal" code is working but the CallBack doesn't. Maybe it is a problem with the company guide lines for macros? In my company all macros are disabled, so maybe that's the reeason, the Callback cannot be registered.

    I am currently on AO 2.7.300.86673

    I hope this will help you a little bit.

    Add comment
    10|10000 characters needed characters exceeded