View Single Post
  #10   Report Post  
Posted to microsoft.public.word.docmanagement
Zaigham Farooqui Zaigham Farooqui is offline
external usenet poster
 
Posts: 1
Default This is a multi-part message in MIMEformat.------=_NextPart_000_0012_01CAEE06.

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

On Friday, May 07, 2010 3:09 PM Ernie&Bert wrote:


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



On Friday, May 07, 2010 3:26 PM Stefan Blom wrote:


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

--
Stefan Blom
Microsoft Word MVP
(Message posted via NNTP)



On Friday, May 07, 2010 4:57 PM Jay Freedman wrote:


This is a multi-part message in MIME format.

------=_NextPart_000_0012_01CAEE06.6886CE40
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: 7bit

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

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
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.

--
Stefan Blom
Microsoft Word MVP
(Message posted via NNTP)





------=_NextPart_000_0012_01CAEE06.6886CE40
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
HTMLHEAD
META content=3D"text/html; charset=3Dwindows-1252" =
http-equiv=3DContent-Type
META name=3DGENERATOR content=3D"MSHTML 8.00.6001.18904"
STYLE/STYLE
/HEAD
BODY bgColor=3D#ffffff
DIVFONT size=3D2 face=3DVerdanaTake a look at Graham Mayor's example =
at A=20
href=3D"http://www.gmayor.com/formatting_word_fields.htm#cash_amounts_in_=
words"http://www.gmayor.com/formatting_wor..._amounts_in_w=
ords/A,=20
following the paragraph that begins "SPAN class=3Dq2FONT size=3D2 =
face=3DArialThe=20
method has problems with numbers over 1 =
million/FONT/SPAN"./FONT/DIV
DIVFONT size=3D2 face=3DVerdanaBR-- BRRegards,BRJay =
FreedmanBRMicrosoft=20
Word MVP        FAQ: A=20
href=3D"http://word.mvps.org"http://word.mvps.org/ABREmail cannot =
be=20
acknowledged; please post all follow-ups to the newsgroup so all may=20
benefit./FONT/DIV
BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; =
PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px"
DIV"Stefan Blom" <A=20
=
m"StefanBlom@discussio=
ns.microsoft.com/A>=20
wrote in message A=20
=
seems as if only numbers smaller than or equal to 999,999 can be =
represented=20
BRas cardinal text.BRBR-- BRStefan BlomBRMicrosoft Word=20
MVPBR(Message posted via NNTP)BRBRBRBR"Ernie&Bert" =
<A=20
=
t.com"Ernie&Bert@d=
iscussions.microsoft.com/A>=20
wrote in message BRA=20
=
/A...BR>I=20
have tried both DollarText and CardText, but it errors out with =
theBR>=20
following message:BR> Error! Number Cannot Be Represented In =
Specified=20
Format.BR>BR> Using Word 2007 =
BRBR/BLOCKQUOTE/BODY/HTML

------=_NextPart_000_0012_01CAEE06.6886CE40--



On Friday, May 07, 2010 10:15 PM Doug Robbins - Word MVP wrote:


' 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



On Saturday, May 08, 2010 7:48 AM Stefan Blom wrote:


Great!

--
Stefan Blom
Microsoft Word MVP
(Message posted via NNTP)



Submitted via EggHeadCafe
SQL Operations on a Text File with ADO.NET
http://www.eggheadcafe.com/tutorials...th-adonet.aspx