IT Community - Software Programming, Web Development and Technical Support

How to Create word Macro that converts currency in numbers into words?

This is a discussion on How to Create word Macro that converts currency in numbers into words? within the VB.NET Programming forums, part of the Software Development category; How to Create word Macro that converts currency in numbers into words?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > VB.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  2 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 07-25-2007, 04:02 AM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 547
itbarota is on a distinguished road
Question How to Create word Macro that converts currency in numbers into words?

How to Create word Macro that converts currency in numbers into words?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-25-2007, 04:03 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Default Re: How to Create word Macro that converts currency in numbers into words?

Open MSword
Click file>close (no more open documents)
Click tools>macros>Visual basic editor
On the left hand side tree-view, expand 'normal'>'Microsoft word objects' to see 'ThisDocument'
Double click on 'ThisDocument'
A white (probably blank) window will appear on the
right hand side, where you should paste the following code
Close all the windows. Installation is complete!

Now when you are typing a document,
if want to use the converter,
Select the number which you want to convert.
Press Alt+F8.
Press Enter. (check for 'RSconvert' in 'Macro name' text field)
This will replace the selected number with its
word equivalent

Dim arrSingleDigit
Dim arrTeen
Dim arrTwoDigits
Sub RSconvert()
On Error Resume Next
arrSingleDigit = Array("one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten")
arrTeen = Array("eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty")
arrTwoDigits = Array("10", "twenty ", "thirty ", "forty ", "fifty ", "sixty ", "seventy ", "eighty ", "ninety ", "Hundred")

valdig = Trim("" + Selection.Text)
If valdig = "" Or IsNumeric(valdig) = False Then Exit Sub
valInDigits = valdig
paisa = Int(valInDigits * 100 - Int(valInDigits) * 100)
valInDigits = Int(valInDigits)

If valInDigits > 0 Then
If valInDigits > 999999999 Then
MsgBox "Beyond Limit"
Else
msgtmp = convert(valInDigits) + " Rupees"
If paisa <> 0 Then msgtmp = msgtmp + " and " + convert(paisa) + " Paisa"
msgtmp = UCase(Left(msgtmp, 1)) + Right(msgtmp, Len(msgtmp) - 1)
Selection.Text = msgtmp
Exit Sub
End If
End If
End Sub
Private Function convert(valInDigits)
Dim MSB
Dim LSB
If valInDigits > 0 And valInDigits < 10 Then
converted = arrSingleDigit(valInDigits - 1)
ElseIf valInDigits = 10 Then
converted = "ten"
ElseIf ((valInDigits > 10) And (valInDigits < 20)) Then
converted = arrTeen(valInDigits Mod 10 - 1)
ElseIf ((valInDigits >= 20) And (valInDigits <= 99)) Then
MSB = valInDigits \ 10
converted = arrTwoDigits(MSB - 1)
LSB = valInDigits Mod 10
If LSB > 0 Then
converted = converted + convert(LSB)
End If
ElseIf ((valInDigits >= 100) And (valInDigits <= 999)) Then
MSB = valInDigits \ 100
converted = convert(MSB) + " " + "hundred"
LSB = valInDigits Mod 100
If LSB > 0 Then
converted = converted + " " + convert(LSB)
End If
ElseIf ((valInDigits >= 999) And (valInDigits <= 99999)) Then
MSB = valInDigits \ 1000
converted = convert(MSB) + " " + "thousand"
LSB = valInDigits Mod 1000
If LSB > 0 Then
converted = converted + " " + convert(LSB)
End If
ElseIf ((valInDigits >= 99999) And (valInDigits <= 9999999)) Then
MSB = valInDigits \ 100000
converted = convert(MSB) + " " + "lakh"
LSB = valInDigits Mod 100000
If LSB > 0 Then
converted = converted + " " + convert(LSB)
End If
ElseIf ((valInDigits >= 9999999) And (valInDigits <= 999999999)) Then
MSB = valInDigits \ 10000000
converted = convert(MSB) + " " + "crore"
LSB = valInDigits Mod 10000000
If LSB > 0 Then
converted = converted + " " + convert(LSB)
End If
End If
convert = converted
End Function
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/vb-net-programming/2714-how-create-word-macro-converts-currency-numbers-into-words.html
Posted By For Type Date
How to Create word Macro that converts currency in numbers into words? | Web Hosting This thread Refback 02-26-2008 12:16 PM
How to Create word Macro that converts currency in numbers into words? | yourmuses This thread Pingback 10-29-2007 09:16 AM

Similar Threads
Thread Thread Starter Forum Replies Last Post
Currency format Kirubhananth ASP and ASP.NET Programming 2 03-13-2008 03:26 AM
what is flapjax and what are its benefits compared to javascript . How it converts fl itbarota HTML, CSS and Javascript Coding Techniques 1 11-21-2007 02:55 AM
SQL reserved words itbarota Database Support 1 09-26-2007 09:53 AM
Embedded Currency Conversion Alkazar HTML, CSS and Javascript Coding Techniques 1 08-27-2007 07:57 AM
How to Create an Excel Macro that converts currency in numbers into words? itbarota VB.NET Programming 2 08-08-2007 06:23 AM


All times are GMT -7. The time now is 12:14 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0