Has anyone experienced this while using the MakeName Function. When I run the following in the immediate window:
MakeName("Test" & char(160) & "String")
I get this error:
It appears MakeName as a problem with converting the ascii Character 160.
Solved! Go to Solution.
Solved by ebachrach. Go to Solution.
This is an interesting error message, but MakeName needs to have a legal Name in the string it is given, and char(160) is not a legal name character. 160 is Unicode 00A0, which is a non-breaking space, which is considered whitespace, and these are not legal in identifiers. I agree the error message could be a lot more clear, but that is the bottom line.
The workaround is to use a legal name character. The rules for names and identifiers are in the help.
Perhaps for your needs you could use char(32), which is supported?
Elly
Thanks Elly that is exactly what I did:
<%%Category("CustomFunctions")> _ Function CustomMakeName( str As String) As Name Dim s_ModStr As String = NoValue If str.contains(Char(160)) Then s_ModStr = StringReplace(str, Char(160), Char(32)) Else s_ModStr = str End If Return MakeName(s_ModStr) End Function
Since MakeName is documented to replace "illegal" characters with an underscore, I have entered a defect DE2116 to get it fixed.
In addition, based on this question, we discovered that the Name datatype had been left out of the documentation! That too, is getting fixed.