Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 663
  • Last Modified:

How to tell word to spell out a number in digits

I have a very large amount of numbers in word that needs to be presented in both ways, numbers and spelled out. All the numbers are present in digits, but so far I need to type them manually to have them spelled out. Is there a way to automatically do this?
0
mvp1985
Asked:
mvp1985
  • 3
  • 3
  • 2
  • +2
1 Solution
 
EirmanCommented:
There is no way to do it natively in word. You will have to use this macro.
http://word.tips.net/T000203_Converting_Numbers_to_Text.html
0
 
frankhelkCommented:
Open the VBA editor and put this into your document's or normal.dot macro code:

Sub Digits2Numbers()

    Dim digits As String
    Dim spelled As String
    
    digits = Selection.Text
    spelled = "#"
    
    For i = 1 To Len(digits)
        If i > 1 And Len(digits) > 1 Then spelled = spelled + "-"
        Select Case Mid(digits, i, 1)
        Case "0"
            spelled = spelled + "Zero"
        Case "1"
            spelled = spelled + "One"
        Case "2"
            spelled = spelled + "Two"
        Case "3"
            spelled = spelled + "Three"
        Case "4"
            spelled = spelled + "Four"
        Case "5"
            spelled = spelled + "Five"
        Case "6"
            spelled = spelled + "Six"
        Case "7"
            spelled = spelled + "Seven"
        Case "8"
            spelled = spelled + "Eight"
        Case "9"
            spelled = spelled + "Nine"
        Case "."
            spelled = spelled + "Dot"
        Case ","
            spelled = spelled + "Comma"
        Case "$"
            spelled = spelled + "Dollar"
        Case " "
            spelled = spelled + "Space"
        Case "-"
            spelled = spelled + "Minus"
        Case "+"
            spelled = spelled + "Plus"
        Case Else
            spelled = spelled + "???"
        End Select
    Next i
    spelled = spelled + "#"

    Dim objClipboard As Object
    Set objClipboard = CreateObject("new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
    objClipboard.SetText spelled
    objClipboard.PutInClipboard
    Set objClipboard = Nothing
End Sub

Open in new window


Add the macro to your menu strip and/or assign a shortkey combination to it.

Usage:

Type the number you want to convert, and select it. Run the macro. The converted number will be in the clipboart afterwards. To replace the number just type CRTL-V afterwards, since the number string is already selected. To use it elsewhere, just navigate to theright spot and press CTRL-V there.

Example:

     123456 78,90.5x+-

would return in the clipboard

     #One-Two-Three-Four-Five-Six-Space-Seven-Eight-Comma-Nine-Zero-Dot-Five-???-Plus-Minus#

For different start/end coding and separator just adjust the strings in the code ...

By the way that macro is independent to the number's length ... and with some more things in the select statement it could even be used tor translating text into a phonetic alphabet (Alpha, Bravo, Charlie, Delta, Echo, ... see here for more info).
0
 
EirmanCommented:
Experiment with this ....

Select a number in word (e.g. 2750)
Press Ctrl+F9 to embed it in a field.
Use Alt+F9 to show/hide the field as necessary.

Edit the field to match the following format:
{=VALUE \* CardText}      that is .... {=2750 \* CardText}

Press F9 to update the field.    Result = two thousand seven hundred fifty
0
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 
GrahamSkanCommented:
Eirman,
Missed your welcome later contribution.
0
 
EirmanCommented:
Point noted and taken on board GrahamSkan
0
 
Eric FletcherCommented:
Depending on how the numbers are presented, consider using the CardText formatting switch with in a field code.

For example, if your numbers were able to be referenced using MailMerge as, say, a variable names "Amount", you could use a field code with switches like this: {MERGEFIELD "Amount" \*CardText } to display a result like one thousand five hundred seventy-one (see image below)). Many formatting switches are available to manage how values are displayed with many of Word's field codes. See the Microsoft article here (Insert and format field codes in Word 2010; the same switches are available in older and newer versions).

The screen captures below show the merge codes first as seen in MailMerge; then as field codes (press Alt-f9 to toggle the view); and then as displayed when  the merged value of Amount was 1,570.76 (note the rounding in the CardText examples).
Field code switches to spell out numbersThe grey shading in the samples above identifies field codes and their results in the screen view (i.e. it won't be printed). This visibility is very useful to be able to detect content that is a result of a field code calculation amongst normal typed content. I always have it turned on: File Options > Advanced > Show document content, Field shading=Always.
0
 
Eric FletcherCommented:
An addendum to my comment above: If you want to have the field code results converted to text instead of existing as calculated field codes, select the results and press Ctrl-Shift-F9. For the mail merge field codes, just run the "Finish & Merge" to produce a new document with the values.
0
 
mvp1985Author Commented:
The {MERGEFIELD "Amount" \*CardText } works perfect and is exactly what I need. But how can I assign the previous form field instead of "Amount"? This is important, since I run a macro on exiting the form field that has the number in digits, that unprotected the document, pastes a new page with the same form fields and text, and then re-protects the document.

Since the price is always different on each document page, but the formfield that contains the correct digits is always the one before the spelled out number, I know bookmarks would not work, unless there is a way to create a bookmark every time the makro runs upon exiting the price form field.
Any suggestions on this?
0
 
Eric FletcherCommented:
I'm not sure I follow what you need to do here. Can you post an example?

The format switches will work with any field code that can return a numeric value, but you'd need to find away to refer to the value in some way with a field code. Perhaps the STYLEREF could be used if you can have the value from the formfield result tagged with a style as shown below.
Using STYLEREF to report a value as cardinal textFor clarity, I captured the 1st screen shot in the Draft mode so the paragraph style names would be shown in the style area pane on the left (File Options > Advanced > Display, Style area pane width in Draft and Outline views). The style pane will only show the style name associated with paragraphs, so I set the character style colour to brown to make it more visible. This can be handy for testing, and you can change the style's colour back to Auto once you know it works okay.
0
 
mvp1985Author Commented:
Basically I am developing a word document that is used for evaluations of art and jewelery for which i use form fields and text describing what goes into the form field. I do this so I can quickly enter the text and then just advance with the tab key. Since every customer is different, I don't know ho many items I need to evaluate, so I use a macro, which runs at the exit of the last form field on the page, that enters a page break, and the same form fields and descriptions (in order for this to work, the macro unprotects the document, and later protects it again, so I can use tab again).  The last item I enter is the estimated price of the piece, but for legal purposes I also need to enter it in non-numerical form right beneath the numerical form. (so for example:

 Estimated price: $40.00
                                 Forty US Dollar

The mergefield you mentioned earlier works perfectly when I enter the number into the "amount" when I establish the meregield. But, since I have often hundreds over hundreds of these prices, I would love for a way that it is automated completley, and all I need to do is put the numerical price in, and the non-numerical amount is automatically entered below. So yes, I need to find a way to refer to the numeric value somehow. Any suggestions on how to refer automatically?
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 3
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now