PA for Excel isConnected VBA Function
Posted: Wed Aug 12, 2020 7:59 pm
Assuming you're using IBM Planning Analytics for Excel (PAX/PAFE) alongside the API as documented by IBM, I wanted to share a VBA function that will return True when users are successfully logged into the target server.
More effective than my prior approach of calling for TM1User given caching. I figured putting this up here will save other people time.
Take care.
Code: Select all
Function isConnected(givenConf As Boolean) As Boolean
' In the below row, substitute XXXXXXX with your ServerName
Dim apiHeader As String: apiHeader = "/tm1/XXXXXXX/api/v1/ActiveSession/User/IsActive"
Dim apiResponse As Object
If Reporting.ActiveConnection Is Nothing Then
Exit Function
Else
Set apiResponse = Reporting.ActiveConnection.Get(apiHeader)
End If
If apiResponse Is Nothing Then
Exit Function
End If
If apiResponse.Properties.Item("value").Value = "true" Then
isConnected = True
Else
Exit Function
End If
End Function
Take care.