PA for Excel isConnected VBA Function

Post Reply
Adam
Posts: 106
Joined: Wed Apr 03, 2019 12:10 am
OLAP Product: IBM PA
Version: 2.0.9.x
Excel Version: Microsoft 365 x64

PA for Excel isConnected VBA Function

Post by Adam »

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.

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
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.
I've started blogging about TM1, check it out: www.havaslabs.com

Take care,
Adam
Wim Gielis
MVP
Posts: 3128
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: PA for Excel isConnected VBA Function

Post by Wim Gielis »

Thanks Adam
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Post Reply