2024 Feb 29 3:31 PM - edited 2024 Feb 29 4:33 PM
Dear experts, I have created a custom VBA code which checks if a certain Planning View filter is present in a certain Worksheet of a Planning View.
It checks this using SOPFilterValueIsValid before refreshing the Planning View, using Function BEFORE_REFRESH()
See also Planning with Microsoft Excel > ... > SAP IBP Hooks (VBA Events) > BEFORE_REFRESH.
Function BEFORE_REFRESH() As Boolean
If Not SOPFilterValueIsValid() Then
BEFORE_REFRESH = False
Exit Function
Else
BEFORE_REFRESH = True
Exit Function
End If
End Function
My question is: how to exit this Function in VBA completely without the need for an additional click anywhere in the MS Excel application (outside the 'Process in progress. Please wait...' dialog box). This click seems currently necessary unfortunately with the above code.
Please note: if SOPFilterValueIsValid is False, then we do not want to Refresh the Planning View (we do not want to 'apply' any refreshing with a wrong filter). This behaviour is already correct according to the above code.
Request clarification before answering.
Hi Vincent,
May you try this below piece of code.
Private IBPAutomationObject As Object
Function BEFORE_REFRESH()
Dim attributeValues() As String
On Error GoTo ErrorHandling:
If IBPAutomationObject Is Nothing Then
Set IBPAutomationObject = Application.COMAddIns("IBPXLClient.Connect").Object
attributeValues = IBPAutomationObject.GetFilterValues(ActiveSheet)
If Trim(attributeValues) = vbNullString Then
'BEFORE_REFRESH = False
MsgBox "Invalid Filter", vbOKOnly
Exit Function
Else
'BEFORE_REFRESH = True
Call IBPAutomationObject.Refresh
End If
ErrorHandling:
MsgBox Err.Description, vbOKOnly
End Function
Best Regards,
'Riyaz'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@vincentverheyen 'EndIf' for IBPAutomationObject check and assignment is not mentioned in any sample codes. I can understand that it is not inline with VBA syntax, yet I din't get any errors.
User | Count |
---|---|
6 | |
6 | |
4 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.