cancel
Showing results for 
Search instead for 
Did you mean: 

Not refreshing automatically after Selection

former_member312721
Participant
0 Kudos

Hi,

whenever the selection of profit center, the sheet has to refresh automatically. i have written VB macros and enable refresh options. but still, it is not refreshing after selection.

attached scrrenshot.

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Kudos

Easy! First I don't see FPMXLClient reference:

Second: simple working code:

Option Explicit

Dim epm As New FPMXLClient.EPMAddInAutomation

Public Function AFTER_CONTEXTCHANGE() As Boolean
    Dim wshCurrent As Worksheet
    Dim objCurrent As Object
    
    Set wshCurrent = ThisWorkbook.ActiveSheet
    If wshCurrent.Name = "Sheet1" Then
        Set objCurrent = Application.Selection 'Save current selection
        wshCurrent.Range(epm.GetDataTopLeftCell(wshCurrent, "000")).Select
        epm.RefreshActiveReport
        objCurrent.Select 'Restore current selection
    End If
End Function
former_member186338
Active Contributor

If you prefer to use universal code working with both EPM Add-In and AO with late binding and without referencing FPMXLClient, then:

Instead of

Dim epm As New FPMXLClient.EPMAddInAutomation

Use inside your procedure:

    Dim objAddIn As COMAddIn
    Dim epm As Object
    Dim AOComAdd As Object
    Dim blnEPMInstalled As Boolean

    'Universal code to get FPMXLClient for standalone EPM or AO
    For Each objAddIn In Application.COMAddIns
        If objAddIn.progID = "FPMXLClient.Connect" Then
            Set epm = objAddIn.Object
            blnEPMInstalled = True
            Exit For
        ElseIf objAddIn.progID = "SapExcelAddIn" Then
            Set AOComAdd = objAddIn.Object
            Set epm = AOComAdd.GetPlugin("com.sap.epm.FPMXLClient")
            blnEPMInstalled = True
            Exit For
        End If
    Next objAddIn
    
    If Not blnEPMInstalled Then
        MsgBox "Error! EPM not installed!"
        Exit Sub
    End If
    epm.RefreshActiveReport ' or any other

Sample in my blog: https://blogs.sap.com/2019/06/24/bpc-nw-10-vba-function-to-get-bassomeparent-dimension-members-list/

Answers (1)

Answers (1)

former_member312721
Participant
0 Kudos

Thank you issue resolved...