Click here to Skip to main content
15,917,565 members
Articles / Desktop Programming / ATL

Number Speller COM-ponent

Rate me:
Please Sign up or sign in to vote.
4.60/5 (6 votes)
18 Feb 2009CPOL1 min read 35.2K   452   10   8
Component used to convert a numeric value into English/Romanian words in Excel

The original article: COM Number Speller.


Some time ago, I needed to print numbers as text in Excel (Office 2003 as far as I remember). Searching the internet, I found a solution for English language, but not for Romanian language.

So, I created a reusable piece of code that may be easily used in as many environments as possible. I chose COM and ATL to be the solution to this 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.

Using the Code  

To install the COM object, just simply run Install.bat in archive.
Here is the Excel macro that makes use of the NumberSpeller COM object:

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

Here is another example of using the component from WSH script:

// Create the speller object.
var speller = new ActiveXObject("NumberSpeller.Speller");

// Set Romanian language
speller.language = "en";

// Modify the  number constant below.
var numberToTranslate = 101001;

// Translate number to text.
    var textNumber = speller.Translate(numberToTranslate);
catch (e)
    // Display details about any thrown exceptions.
    WScript.Echo( + ": " + e.description + "  " + e.number);

Points of Interest

  • Error info support by implementing IErrorInfo interface.
  • Help in CHM format and context identifiers specified in MIDL source file.
  • BSTR manipulation using CComBSTR class provided by ATL
  • IDispatch support, so the component can be used from scripting environments.
  • Spelling implementation itself and support for multiple languages (only Romanian and English for now).  


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Software Developer (Senior) Codecentrix Software
Romania Romania
Software consultant in Bucharest Romania writing Windows programs and browsers plug-ins since 1998 with Visual C++.

Comments and Discussions

GeneralGood job! Pin
Maze27-May-09 6:52
Maze27-May-09 6:52 
GeneralModified English Version Pin
Synaptrik18-Feb-09 7:54
Synaptrik18-Feb-09 7:54 
JokeRe: Modified English Version Pin
Adrian Dorache18-Feb-09 9:21
Adrian Dorache18-Feb-09 9:21 
If at least one person on earth find this code useful, then my mission is complete :--)

GeneralRe: Modified English Version Pin
Synaptrik18-Feb-09 9:23
Synaptrik18-Feb-09 9:23 
Generalseventeen is mispelled.. Pin
Synaptrik17-Feb-09 13:59
Synaptrik17-Feb-09 13:59 
GeneralRe: seventeen is mispelled.. Pin
Adrian Dorache18-Feb-09 3:13
Adrian Dorache18-Feb-09 3:13 
QuestionCom Component? Why? Pin
ednrg14-Jan-09 5:32
ednrg14-Jan-09 5:32 
AnswerRe: Com Component? Why? Pin
Adrian Dorache14-Jan-09 5:55
Adrian Dorache14-Jan-09 5:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.