Some time ago, I was asked to provide a way to print numbers as text in Romanian language. Interestingly, I couldn't find an easy way to do this in Excel (Office 2003 as far as I remember). Searching the internet, I found other people having the same problem. Microsoft provides a solution for English language, but not for Romanian.
I decided to create a reusable piece of code that will be easily used in as many environments as possible. I chose COM and ATL to be the solution to my problem. This is also a good programming exercise for my rusty COM / C++ skills and I plan to use it as a template for all my future COM objects.
Points of interest:
Function Spell(n As Currency) As String
'Create the speller object.
Dim s As NumberSpellerLib.speller
Set s = New NumberSpellerLib.speller
Dim o As Object
Set o = s
o.Language = "ro"
Spell = o.Translate(n)
End Function
Downloads:
full source code and compiled DLL | NumberSpeller.zip | |
C++ sample code | NumberSpellerSample1.zip | |
Excel sample file | NumberSpellerSample2.zip | |
JS sample file | NumberSpellerSample3.zip |