How do you display 1,000,000 in text.

E

Ernie&Bert

I have tried both DollarText and CardText, but it errors out with the
following message:
Error! Number Cannot Be Represented In Specified Format.

Using Word 2007
 
S

Stefan Blom

It seems as if only numbers smaller than or equal to 999,999 can be represented
as cardinal text.
 
J

Jay Freedman

Take a look at Graham Mayor's example at
http://www.gmayor.com/formatting_word_fields.htm#cash_amounts_in_words,
following the paragraph that begins "The method has problems with numbers
over 1 million".

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
It seems as if only numbers smaller than or equal to 999,999 can be
represented
as cardinal text.
 
D

Doug Robbins - Word MVP

' a Macro to insert cardtext for numbers up to 999,999.999,999
' Macro created 29/09/99 by Doug Robbins
With Selection.Find
.Text = ","
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
End With
Selection.Find.Execute Replace:=wdReplaceAll
numtext$ = Int(Val(Selection.Text))
If Val(numtext$) < 1000000 Then
Selection.Delete
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
PreserveFormatting:=False
Selection.TypeText Text:="=" & Val(numtext$) & " \* CardText"
ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
Selection.Fields.Update
ElseIf Len(numtext$) < 10 Then
millions = Val(Left(numtext$, Len(numtext$) - 6))
Balance = Val(Right(numtext$, Len(numtext$) - Len(millions)))
Selection.Delete
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
PreserveFormatting:=False
Selection.TypeText Text:="=" & millions & " \* CardText"
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeText Text:=" million "
Selection.Collapse Direction:=wdCollapseEnd
If Balance <> 0 Then
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
PreserveFormatting:=False
Selection.TypeText Text:="=" & Balance & " \* CardText"
End If
ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
ActiveDocument.Fields.Update
ElseIf Len(numtext$) < 14 Then
billions = Val(Left(numtext$, Len(numtext$) - 9))
millions = Val(Mid(numtext$, Len(billions) + 1, 3))
Balance = Val(Right(numtext$, Len(numtext$) - Len(millions) -
Len(billions)))
Selection.Delete
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
PreserveFormatting:=False
Selection.TypeText Text:="=" & billions & " \* CardText"
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeText Text:=" billion "
Selection.Collapse Direction:=wdCollapseEnd
If millions <> 0 Then
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
PreserveFormatting:=False
Selection.TypeText Text:="=" & millions & " \* CardText"
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeText Text:=" million "
Selection.Collapse Direction:=wdCollapseEnd
End If
If Balance <> 0 Then
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
PreserveFormatting:=False
Selection.TypeText Text:="=" & Balance & " \* CardText"
End If
ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
ActiveDocument.Fields.Update
End If



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
Z

Zaigham Farooqui

Macro was copied from forum and pasted but compile Error: Syntax Error message was given at the following line. What is wrong. I have not used macros in MS Word before this.

Balance = Val(Right(numtext$, Len(numtext$) - Len(millions) -
Len(billions)))

Regards
Zaigham
 
J

Jay Freedman

Macro was copied from forum and pasted but compile Error: Syntax Error message was given at the following line. What is wrong. I have not used macros in MS Word before this.
Balance = Val(Right(numtext$, Len(numtext$) - Len(millions) -
Len(billions)))

Regards
Zaigham

Because the macro was posted from software that limits the length of the lines, an unwanted line break was inserted into the code. Those two lines should be one line, like this:

Balance = Val(Right(numtext$, Len(numtext$) - Len(millions) - Len(billions)))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top