Search

VBA Function to check if User is currently Connected to Certain Cube


You can use below tested VBA function to check if current user is currently connected to a TM1 Cube.

Function IsConnectedTo(xServer) As Boolean

'-----------------------------
'Thanks for downloading the code. 
'Please visit our channel for a quick explainer on this code.
'Feel free to update the code as per your need and also share with your friends.
'Channel: Youtube.com/vbaa2z
'Download free codes from http://vbaa2z.blogspot.com
'Autor: L Pamai (vbaa2z.team@gmail.com)
'-----------------------------

On Err GoTo tm1err_x1
Dim x
IsConnectedTo = False
x = Application.Run("TM1USER", xServer)
If Len(x & vbNullString) > 0 Then IsConnectedTo = True
Exit Function
tm1err_x1:
IsConnectedTo = False
End Function

Usage example:

Sub TestCode()

If IsConnectedTo("ENTER YOUR CUBE OR SERVER NAME HERE") Then
    'is connected proceed with your codes...
    Else
    MsgBox "Please ensure that you are connected to XTM1CUBE and try again"
End If
End Sub

No comments:

Post a Comment

Note: only a member of this blog may post a comment.