Quote:
Originally Posted by kahheng93
i tried the link,first method do not allow me to edit the words such as 'dollars'
|
Microsoft’s ‘DollarText’ field switch doesn’t allow you to specify anything other than dollars. It also doesn't express a value as ‘X dollars and Y cents’ – it returns ‘X and Y/00’. Here’s a field code that takes a more sophisticated approach that allows you to change the currency and use much greater values:
Code:
{QUOTE {ASK Val "What is he amount?"}
{SET AbsVal {=ABS(Val)}}
{IF{=Val}< 0 "Minus "}
{IF{=INT(AbsVal/100000000)}<> 0 "{=INT(AbsVal/100000000) \*Cardtext} hundred "}
{IF{=MOD(INT(AbsVal/1000000),100)} <> 0 "{IF{=INT(AbsVal/100000000)}<> 0 "and "}"}
{IF{=INT(AbsVal/1000000)}<> 0 "{=MOD(INT(AbsVal/1000000),100) \*Cardtext} million, "}
{IF{=INT(AbsVal/100000)}<> 0 "{=MOD(INT(AbsVal/100000),10) \*Cardtext} hundred "}
{IF{=MOD(INT(AbsVal1000),100)} <> 0 "{IF{=INT(AbsVal/100000)}<> 0 "and "}"}
{IF{=INT(AbsVal/1000)}<> 0 "{=MOD(INT(AbsVal/1000),100) \*Cardtext} thousand, "}
{IF{=MOD(INT(AbsVal/100),10)}<> 0 "{=MOD(INT(AbsVal/100),10) \*Cardtext} hundred "}
{IF{=MOD(INT(AbsVal),100)}<> 0 "{IF{=INT(AbsVal/100)}<> 0 "and "}{=MOD(INT(AbsVal),100) \*Cardtext} "}
{=INT(AbsVal) \# \dollar;;}{IF{=INT(AbsVal)}> 1 "s"}
{IF{=MOD(AbsVal,1)}<> 0 "{IF{=INT(AbsVal)}<> 0 " and "}{=MOD(AbsVal,1)*100 \*Cardtext} cent{IF{=MOD(AbsVal,1)}> 0.01 s}"} \* FirstCap}
With this field you can go all the way to 999,999,999.99 (technically you could go two orders of magnitude higher). You can omit/edit the:{=INT(Val) \# \dollar;;}{IF{=INT(Val)}> 1 "s"} and {IF{=MOD(Val,1)}> 0.01 cents cent}"}portions if you want no/different currency. You could likewise omit the various tests for inserting 'and ', if you prefer.
Note: The field brace pairs (ie '{ }') for the above example are created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message.
You could also use a macro to convert the above to a working field. For that, see:
http://www.gmayor.com/export_field.htm#TextToField
Quote:
second method has compile error syntax error when trying to run
|
That solution is designed for working with formfields only. Does your document contain the required formfields - with the required names?
Quote:
third method has errors when running the add-ins suchs as : "Could not load an object because it is not available on this machine" or "Compile error in hidden module" or macro cannot be found or has been disabled because of your macro security settings"
|
Did you install the correct version, as per the instructions given on that site?
Quote:
I tried enabled all macros in trust center and trust access to vba project object model... nothing works so far...
|
None of that should be necessary; indeed it opens your PC to macro virus attacks.