Microsoft Office Forums Dollar amount in words
 User Name Remember Me? Password
 Register FAQ Search Today's Posts Mark Forums Read

 Thread Tools Display Modes
#1
11-18-2022, 10:40 AM
 rprice124 Windows 10 Office 2019 Novice Join Date: Nov 2022 Posts: 3
Dollar amount in words

I'm in need of some expert help, i'm trying to switch a dollar amount into words, with dollars and cents. Below is what i have and it's returning to blank, not sure what i'm missing on this, but any suggestions would be greatly appreciated!

(Quote{Set Val {MERGEFIELD PCORevTotalCons}"=INT(Val)\* CardText} dollar{ =Int(Val)-1 \# "s;s;"}{ IF{=MOD(Val,1) \#0.00}>0 " and { ={ =MOD(Val,1)*100 \ # 0 } \* CardText } cent{ = INT(MOD(Val,1)*100-1) \# "s;s;" }" " and zero cents"}" \* First Cap}
#2
11-18-2022, 04:05 PM
 macropod Windows 10 Office 2016 Administrator Join Date: Dec 2010 Location: Canberra, Australia Posts: 21,861

Your field coding has various errors. Try:

{QUOTE{SET Val «PCORevTotalCons»}{=INT(Val) \* CardText}" dollar{=INT(Val)-1 \# "s;s;"}"
{IF{=MOD(Val,1) \# 0.00}> 0 " and {=MOD(Val,1)*100 \# 0 \* CardText} cent{=INT(MOD(Val,1)*100-1) \# "s;s;"}"} \* FirstCap}

You'll find essentially the same field coding in the Mailmerge Tips & Tricks 'Sticky' thread at the top of this page (https://www.msofficeforums.com/mail-...ps-tricks.html), under the heading Mailmerge Number & Currency Formatting

Note: The field brace pairs (i.e. '{ }') for the field code example above are all created in the mailmerge main document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from here. Nor is it practicable (for the most part) to add them via the standard Word dialogues. The spaces shown in the field constructions are all required. The line break, though, isn't needed - it just there for layout purposes
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
#3
11-21-2022, 06:19 AM
 rprice124 Windows 10 Office 2019 Novice Join Date: Nov 2022 Posts: 3

Thanks for your response macropod, I'm still not getting anything to return when i tried your code, I'm sure I'm missing something in the entry of the code.

I did the Alt F9 then copied and pasted your solution inside the {} of my current code, is there a better way to accomplish this?
#4
11-21-2022, 06:26 AM
 macropod Windows 10 Office 2016 Administrator Join Date: Dec 2010 Location: Canberra, Australia Posts: 21,861

You could use the macro found under Convert Text Representations of Fields to Working Fields in the Mailmerge Tips & Tricks 'Sticky' thread to convert the field representation I posted into a working field.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
#5
11-21-2022, 08:08 AM
 rprice124 Windows 10 Office 2019 Novice Join Date: Nov 2022 Posts: 3

Great! That did the trick greatly appreciate your help!

One last question, if the value is negative, I'm getting an error, is there a way to update the code to switch a negative to a positive?
#6
11-21-2022, 03:20 PM
 macropod Windows 10 Office 2016 Administrator Join Date: Dec 2010 Location: Canberra, Australia Posts: 21,861

Simply change:
{SET Val «PCORevTotalCons»}
to:
{SET Val {=ABS(«PCORevTotalCons»)}}
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]

 Tags mail merge, mail merge code, mail merge help

 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post Formd Mail Merge 2 07-06-2022 01:21 PM Karen615 Excel 8 04-09-2020 03:55 PM Marcia Mail Merge 2 08-08-2019 06:08 AM dstallworth PowerPoint 0 04-23-2017 12:49 PM GeorgeLawshe Word 0 03-07-2010 10:17 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:45 PM.

 -- Default Style -- Lightweight -- New Mobile Contact Us - Privacy Statement - Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2022 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft