Solved

How to tell word to spell out a number in digits

Posted on 2014-11-26
11
371 Views
Last Modified: 2014-11-27
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
Comment
Question by:mvp1985
  • 3
  • 3
  • 2
  • +2
11 Comments
 
LVL 23

Expert Comment

by:Eirman
ID: 40466630
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
 
LVL 13

Expert Comment

by:frankhelk
ID: 40466635
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
 
LVL 23

Expert Comment

by:Eirman
ID: 40466677
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 40466718
Eirman,
Missed your welcome later contribution.
0
 
LVL 23

Expert Comment

by:Eirman
ID: 40466744
Point noted and taken on board GrahamSkan
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 21

Accepted Solution

by:
EricFletcher earned 500 total points
ID: 40468426
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
 
LVL 21

Expert Comment

by:EricFletcher
ID: 40468445
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
 

Author Comment

by:mvp1985
ID: 40468743
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
 
LVL 21

Expert Comment

by:EricFletcher
ID: 40469113
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
 

Author Comment

by:mvp1985
ID: 40469371
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Like many others, we try and discourage users from printing documents unnecessarily and instead send or share them electronically. However, this doesn't always work and documents are still printed. With this simple solution, if the user tries to …
The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now