Excel VBA API Crashing on TM1ObjectListCountGet
Posted: Thu Sep 28, 2017 2:45 am
I've begun delving into TM1's API and am using the sample code provided by TM1 to get started. So far so good, but the following code continues to crash Excel and I don't know why.
It crashes when trying to use the "TM1ObjectListCountGet" function.
It crashes when trying to use the "TM1ObjectListCountGet" function.
Code: Select all
Sub ListCubes()
Dim hUser As Long, hPool As Long, hServer As Long, vbOK As Long
Dim sServerName As String, sClientId As String, sPassword As String
Dim viCubeCount As Long
TM1APIInitialize
hUser = TM1SystemOpen()
sServerName = "RxSandboxAW"
sClientId = "admin"
sPassword = ""
Call TM1SystemAdminHostSet(hUser, "csidcbipt059.ivdc.kp.org")
hPool = TM1ValPoolCreate(hUser)
hServer = TM1SystemServerConnect(hPool, TM1ValString(hPool, sServerName, 0), TM1ValString(hPool, sClientId, 0), TM1ValString(hPool, sPassword, 0))
If TM1ValType(hUser, hServer) = TM1ValTypeError() Then
Debug.Print "Cannot connect to server"
Exit Sub
Else
Debug.Print "Connected to server"
End If
' This is the line that crashes. Determine the number of cubes in the database
viCubeCount = TM1ObjectListCountGet(hPool, hServer, TM1ServerCubes())
vbOK = TM1SystemServerDisconnect(hPool, hServer)
Call TM1ValPoolDestroy(hPool)
Call TM1SystemClose(hUser)
Call TM1APIFinalize
End sub