VBA API: TM1_API2HAN() vs TM1SystemOpen()

Post Reply
User avatar
orlando
Community Contributor
Posts: 167
Joined: Fri Aug 04, 2017 8:27 am
OLAP Product: TM1
Version: PAL 2.0.8
Excel Version: Office 365

VBA API: TM1_API2HAN() vs TM1SystemOpen()

Post by orlando »

Hello!

I have a very old (around 12 to 14 year) planning environment, that uses a lot of VBA.
The user connection is made via VBA (Perspectives I also loaded by a VBA Code) and works fine. The Excelsheets, that are used for planning, are very static and also created by VBA. So, in this old world everything is fine. If I provide active forms to the users, the active forms are not working. It looks like an active form when you forget to start perspectives.
If I change the VBA connection to the second sub – active form work – but the old world doesn’t.
I even tried to put “hUser = TM1_API2HAN()” at the end of the second Sub – with no effect.
Does anybody have an Idea how I could keep the “old world” alive and can make a connect via VBA to use active forms.

Thanks a lot in advance!

### SUB 1
Sub verbindung_herstellen()
Dim AdminHostName, ServerName As String
hUser = TM1_API2HAN()

AdminHostName = ThisWorkbook.Worksheets("Adr").Range("_adm_1")
ServerName = ThisWorkbook.Worksheets("Adr").Range("_sr_1")
ServerName = Left(ServerName, Len(ServerName) - 1)

hPool = TM1ValPoolCreate(hUser)
vServerName = TM1ValString(hPool, Trim(ServerName), 0)
vClientName = TM1ValString(hPool, Trim(UserName), 0)
vClientPassword = TM1ValString(hPool, Trim(Password), 0)

hServer = TM1SystemServerConnect(hPool, vServerName, vClientName, vClientPassword)

If haendel_testen(hServer, "hServer") = "The hServer handle contains an error code." Then
MsgBox "Keine Verbindung"
End If
End Sub


####

### Sub2

Sub con
hUser = TM1SystemOpen()
AdminHostName = ThisWorkbook.Worksheets("Adr").Range("_adm_1")
ServerName = ThisWorkbook.Worksheets("Adr").Range("_sr_1")
ServerName = Left(ServerName, Len(ServerName) - 1)

'AdminHostServer angeben
Call TM1SystemAdminHostSet(hUser, AdminHostName)

ServerCount = TM1SystemServerNof(hUser)

'Einen ValuePool-Handle erstellen
hPool = TM1ValPoolCreate(hUser)

MsgBox AdminHostName + " " + ServerName + " " + UserName + " " + Password
vServerName = TM1ValString(hPool, Trim(ServerName), 0)
vClientName = TM1ValString(hPool, Trim(UserName), 0)
vClientPassword = TM1ValString(hPool, Trim(Password), 0)

'Am TM1-Server anmelden

hServer = TM1SystemServerConnect(hPool, vServerName, vClientName, vClientPassword)

End Sub
Post Reply