samuvk wrote:
I'm trying to get the Alias of an element in a Dimension.
Trying to use this code:
Code: Select all
Dim Element As String
Dim l_DimIdx As Long
Dim Alias As String
l_DimIdx = 1
Element = Application.Run("DIMNM", Server & ":" & Dimension, l_DimIdx, Alias)
If for instance I have a Element named Co.52 which Alias is "A Bank" I'm getting in Alement Co.52 and I'm trying to get "A Bank".
There are several problems there.
The first is that while DimNm
can return an alias, that isn't its primary role. DimNm is for when you need to specify the position number (index) of an element in a dimension, and want to get the name of the element that's in that position. DimNm will return that name, optionally using an alias.
The code that you have above will always return the name of first element in the dimension, regardless of which one that is.
The second problem is that you haven't populated the Alias string variable with the name of the alias that you want. That means that you'll be passing an empty string to the last argument of DimNm, and
that means that you'll just be getting the base name of the element (presumably "Co.52") as you described.
If all you want is the alias, and you want to specify the element that you want the alias for, you may as well use DBRA instead of DimNm:
Code: Select all
Sub AliasDisplay(Server As String, Dimension As String)
Dim s_ElementBaseName As String
Dim s_ElementAlias As String
Dim s_Alias As String
'You'd more likely pass this as a further argument.
s_ElementBaseName = "Co.52"
'You need to specify which alias you want rteturned; let's
'suppose that the alias is called "Desc".
s_Alias = "Desc"
s_ElementAlias = Application.Run("DBRA", _
Server & ":" & Dimension, s_ElementBaseName, s_Alias)
MsgBox s_ElementAlias
End Sub
Edit: Ooops, Mike beat me to it...