Convert Currency in Number to Words in MS Word

Some times we need numbers in both numerical format and in words. Here I am going to explain how to use VBA module to convert Number to Words in Microsoft Word.

If you are looking for a method to use in MS - Excel, please check my earlier blog post : Convert Currency in Number to Words (Indian Rupees) - MS Excel 

 

Step 1: Enable Developer Tab In MS Word

If you can't see the developer tab as like in the below picture, Go to File -> Options -> Customize Ribbon -> Check on 'Devloper' under Main Tabs heading, Developer menu enabling process is explained here.

 

 

Step 2: Add the Module Code

Click on the Visual Basic option in the Developer Ribbon. Right click on the 'Project' title and Insert -> Module

 

Copy and paste the below code in code window of the Module1. 

  1. span style="color: #808080;">' For more info, visit : www.livetolearn.in
  2. " Thousand "
  3. Place(3) = " lakh "
  4. Place(4) = " Crore "
  5.  
  6.  
  7. ' Convert MyNumber to a string, trimming extra spaces.
  8. ' Find decimal place.
  9. ".")
  10.  
  11. ' If we find decimal place...
  12. ' Convert Paise
  13. "00", 2)
  14. ' Hi! Note the above line Mid function it gives right portion
  15. ' after the decimal point
  16. 'if only . and no numbers such as 789. accures, mid returns nothing
  17. ' to avoid error we added 00
  18. ' Left function gives only left portion of the string with specified places here 2
  19. ' Strip off paise from remainder to convert.
  20. ""' Convert last 3 digits of MyNumber to Indian Rupees.
  21. ""' Remove last 3 converted digits from MyNumber.
  22. ""' convert last two digits to of mynumber
  23. """0"""' Remove last 2 converted digits from MyNumber.
  24. ""' Clean up rupees.
  25. ""
  26. Rupees = """One"
  27. Rupees = "One Rupee"" Rupees"' Clean up paise.
  28. ""
  29. Paise = """One"
  30. Paise = "One Paise"" Paise"""""" and ""One""Two""Three""Four""Five""Six""Seven""Eight""Nine"""' Exit if there is nothing to convert.
  31. ' Append leading zeros to number.
  32. "000" & MyNumber, 3)
  33.  
  34. ' Do we have a hundreds place digit to convert?
  35. "0"" Hundred "' Do we have a tens place digit to convert?
  36. "0"' If not, then convert the ones place digit.
  37. ' Is value between 10 and 19?
  38. "Ten""Eleven""Twelve""Thirteen""Fourteen""Fifteen""Sixteen""Seventeen""Eighteen""Nineteen"' .. otherwise it's between 20 and 99.
  39. "Twenty ""Thirty ""Forty ""Fifty ""Sixty ""Seventy ""Eighty ""Ninety "' Convert ones place digit.

 

You can also rename the project title (Right click on the 'Project' title, Project Properties, provide a name you wish. For example 'MyWordTools')

Step 3: Create a shortcut button to run the Macro

Click on the customize quick access button in MS Word Window top bar and chose 'More Commands' option

MS Word - Customize Quick Access Bar

 

Now the Word options window will appear as like below.

Choose Macros from the 'Choose commands from' combo box.

Double click on the our custom module Name, now the icon will be added to the right side. Click 'Ok' to save and close.

MS Word Options - Assigning Macros to button

Now save the document as 'Macro Enabled Word document' (*.docm)

Now select the number in your document, then click on the button in the quick access bar, the number will be converted into words.

Number to Words

 

 

Category: