I'm tinkering with setting the AdminHost with either the macro function OPTSET or an API call to TM1SystemAdminHostSet.
With either method, I'm finding the following behavior:
- List of available TM1 instances is displayed properly reflecting the AdminHost change
- The Server Explorer File-->Options is NOT updated with the new AdminHost
- The tm1p.ini file is NOT updated with the new AdminHost when Excel is closed
- The call is creating a temp file (tm1tmp$) that is not cleaned up and cannot be deleted until Excel is closed
Anyone experienced anything similar? Is there another API call that can be made to update the GUI (I think this will fix the issue with the TM1p.ini file)
Issue with Macro Function and API for Setting Admin Host
-
- MVP
- Posts: 733
- Joined: Wed May 14, 2008 11:06 pm
Re: Issue with Macro Function and API for Setting Admin Host
Are you saying they are or aren't displayed properly? With TM1SystemAdminHostSet you have to also deal with the SSL credentials otherwise you won't correctly retrieve the list of servers being handled by the admin host(s).mberson wrote:I'm tinkering with setting the AdminHost with either the macro function OPTSET or an API call to TM1SystemAdminHostSet.
With either method, I'm finding the following behavior:
- List of available TM1 instances is displayed properly reflecting the AdminHost change
It's not the job of the API to update the ini files, which in turn are presented in the Options dialog. To alter that configuration - which is specific to Perspectives and not your application - you'd have to use some functions in the Windows API. There's a good example of the standard approach here:mberson wrote:- The Server Explorer File-->Options is NOT updated with the new AdminHost
- The tm1p.ini file is NOT updated with the new AdminHost when Excel is closed
Code: Select all
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Public Function IniFileName() As String
IniFileName = "c:\[yourpath here]\settings.ini"
End Function
Private Function ReadIniFileString(ByVal Sect As String, ByVal Keyname As String) As String
Dim Worked As Long
Dim RetStr As String * 128
Dim StrSize As Long
iNoOfCharInIni = 0
sIniString = ""
If Sect = "" Or Keyname = "" Then
MsgBox "Section Or Key To Read Not Specified !!!", vbExclamation, "INI"
Else
sProfileString = ""
RetStr = Space(128)
StrSize = Len(RetStr)
Worked = GetPrivateProfileString(Sect, Keyname, "", RetStr, StrSize, IniFileName)
If Worked Then
iNoOfCharInIni = Worked
sIniString = Left$(RetStr, Worked)
End If
End If
ReadIniFileString = sIniString
End Function
Private Function WriteIniFileString(ByVal Sect As String, ByVal Keyname As String, ByVal Wstr As String) As String
Dim Worked As Long
iNoOfCharInIni = 0
sIniString = ""
If Sect = "" Or Keyname = "" Then
MsgBox "Section Or Key To Write Not Specified !!!", vbExclamation, "INI"
Else
Worked = WritePrivateProfileString(Sect, Keyname, Wstr, IniFileName)
If Worked Then
iNoOfCharInIni = Worked
sIniString = Wstr
End If
WriteIniFileString = sIniString
End If
End Function
Robin Mackenzie
-
- Posts: 30
- Joined: Tue Jun 07, 2011 8:30 pm
- OLAP Product: Planning Analytics
- Version: 2.0
- Excel Version: 2016
Re: Issue with Macro Function and API for Setting Admin Host
Thanks, Robin.
The list of available TM1 servers IS updated properly after my macro is run.
However, if I go to Server Explorer File-->Options the AdminHost displayed there does not match what was set in the macro. Obviously, this could cause some end-user confusion, which is my biggest concern here.
The tm1p.ini file is updated upon exiting, so I think the ini file issue would be resolved by inherently resolving the first issue.
FYI - this happens with both the API call and the out of box macro function, OPTSET.
The list of available TM1 servers IS updated properly after my macro is run.
However, if I go to Server Explorer File-->Options the AdminHost displayed there does not match what was set in the macro. Obviously, this could cause some end-user confusion, which is my biggest concern here.
The tm1p.ini file is updated upon exiting, so I think the ini file issue would be resolved by inherently resolving the first issue.
FYI - this happens with both the API call and the out of box macro function, OPTSET.
Matthew Berson
ACG TM1 Consulting
ACG TM1 Consulting