TeamDesk Knowledge Base & Support

   Home      FAQ      Forum      Idea Exchange      Ask a Question      My Stuff      Help   
  
Number to Text - Microsoft Word - cardtext
Hello to you all

I am struggling to display numbers as text in TeamDesk documents, i.e. displaying thirty-four instead of 34.

In English, I could easily find APIs translating numbers to text.
Ex for integers: https://api.funtranslations.com/translate/numbers.json?text=1234567890

In French, I could not find such an API

So I have created formulas converting numbers to text in French. I saw formulas translating to Spanish in this Forum.
My formulas work; but you have to create one set of formulas in each table where a conversion is needed; and if you manage rather large amounts (> 1 000 000 ) the formulas are somehow complex (many fields to create).

I recently saw that Microsoft Word has a formatting option, applicable to fields, doing the same job : cardtext.
It is simple to use: you create a field, write the formula with the toggle cardtext, ex:
{ = 34 \*cardtext} and it returns thirty four in whatever language you want.

I tried to use cardtext in TeamDesk documents
{MERGEFIELD NumberToConvert \*MERGEFORMAT \*cardtext}
But the numbers are not converted in the TeamDesk generated documents.

Would any of you have any advice in the matter ?

Kind regards,

Pierre
ID
2015
Category
Customization
Author

Pierre
Date Created
10/12/2023 4:47:04 AM
Date Updated
10/12/2023 9:15:03 PM
Comments
basenine 10/12/2023 4:59:09 AM
Hello Pierre

My answer is just a wild guess…
Can you try taking out the \*MERGEFORMAT and just use \*cardtext

When using field switches in the past (\*UPPERCASE) I drop the mergeformat and all works as expected
Best regards
Brett
Pierre 10/12/2023 5:56:44 AM
Hello Brett

Thanks a lot for the idea

It did not work any better

Following your message I checked MS website:
https://support.microsoft.com/fr-fr/office/mettre-en-forme-les-résultats-du-champ-baa61f5a-5636-4f11-ab4f-6c36ae43508c#ID0EBBD=Commutateur_de_mise_en_forme_(\*)
(in French)

1) MS says \*MERGEFORMAT is useless [and actually it works without in TeamDesk]

2) official typing is CardText
No success like this either

Kind regards,

Pierre
basenine 10/12/2023 6:01:56 AM
Hello Pierre.
Did you put the ‘=‘ sign in front of your NumberToConvert?
Pierre 10/12/2023 6:33:36 AM
Hello and thanks again Brett

I had put the "=" sign where it belongs.
But, your support pushed me to dig a bit more in MS documentation and found a 90% solution:

1 - I create a table in the TeamDesk document (word)
2 - I display the number in numbers (ie 34) in some cell of this table (say cell A1)
3 - In an "other cell" of the table, I create another word formula : { = SUM(A1) \* CardText}

The value in the "other cell" is displayed in letters !! 😊

Note:
- The cell A1 can be made invisible with white ink
- I am still struggling for the decimal part, which is not recognized (I might need to ensure the number is A1 is properly written : 34,2 or 34.2 )
- I still do not understand why TeamDesk does not process the \* switch directly

Kind regards,

Pierre


basenine 10/12/2023 6:47:06 AM
That’s good news Pierre
I recently (within 8 months) created a document with a merge field within a merge field.
I’m about to close my eyes for the evening but I’ll dig it out tomorrow and send it through.
This might help instead of having to create a dummy cell
Kirill Bondar  Staff  10/12/2023 7:09:34 AM
It works, with some caveats. Trickiest part is to create properly formatted structure in Word.

Turn on displaying field codes.

Create a formula (via Insert | QuickParts) with { =1 \* CardText } code. Then, select "1" and Insert | QuickParts | MergeField.

You will end up with something like { ={ MERGEFIELD N } \* CardText }, but if fact it's a MergeField structure nested into Formula structure.

You can quickly check if it is done right by placling the cursor before left curly bracket of the MergeField and pressing Shift+Right Arrow -- the cursor should jump over { MERGEFIELD N } code.

Upload the template and set document's Output Format to PDF.

Done.

The language used for number translation matches the locale/language of the user generating the document (or the locale/language of the database in case of periodic/time-dependent triggers)


















What looks like a simple text
Pierre 10/12/2023 8:53:22 AM
Thanks to both of you

With your help I did it 😊😊

I first created a text in Word with two formulas fed by fixed numbers

{ = ABS(12,456) \*CardText } Euros and {= 100*ROUND(ABS(12,456) - INT(ABS(12,456));2) \*CardText}

Where the two {} placeholders are created by INSERT / FIELD / FORMULA [MS Word Menus translated from French]

I update the fields (rightclick) and check that the formulas work
I click the fields to display their formulas
I then Copy the Teamdesk Field «InvoiceAmount» and paste it to replace the values 12,456 in the formulas
I update the fields

For negative numbers, the formula above does not write 'minus'
I could not do it in one formula only (could not display the fractional part properly) - but I needed to split it into 2 parts to write the currency

Kind regards,

Pierre

Pierre 10/12/2023 9:51:10 AM
There is one more issue:

This works when generating PDFs
It does not work when generating .docx documents.

It seems the field update mechanism is different.
With a docx export format,
- the merge field within a merge field is not supported
- If I use a table with the number to translate in cell A1 (for instance), and create a formula in cell A2 referring to cell A1, the merge field are not updated (zero)

Would you see a way around this by any chance ?

Kind regards,

Pierre
basenine 10/12/2023 5:19:09 PM
Nice work.

After reading the above, I can confirm my field was indeed a field within a formula field.
In regards to the ‘-‘ not being recognised, perhaps the INT() part of the formula is ignoring everything but the integer
basenine 10/12/2023 9:15:03 PM
Here's the formula I use in another doc:
{IF "{MERGEFIELD ALTERATION_WORKS \*MERGEFORMAT}"="YES" "" ""}

I was thinking you might be able to have two If statement fields: one for the CardText (which you've already figured out) and one for the '-' symbol:
{IF "{MERGEFIELD ALTERATION_WORKS \*MERGEFORMAT}"<"0" "-" ""}

See if that works for you🙂
Feedback
Back to Search Results