How to use mergefiled with a variable instead of a specific Text.

I have the following Mergefield: {MERGEFIELD "Amount" \*CardText}. Now I need the "Amount" to be always the previous form field. I need this to work when running a macro on exiting the last form field (that has the number in digits), which unprotectes the document, pastes a new page with empty form fields and (always the same) text, and then re-protects the document.

Since the price is always different on each document page, but the formfield that contains the correct digits is always the one before the spelled out number, I know bookmarks would not work, unless there is a way to create a bookmark every time the makro runs upon exiting the price form field.
Any suggestions on this?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Eric FletcherCommented:
I think my last comment on your other related question (here) may work for this.

If your merge document is set up so the formfield with the digits is tagged with a character style, you can use the STYLEREF field code to refer to it — and the \*CardText format switch can be included to display it in cardinal text.

Refer to the description and switch options available for the STYLEREF field code at this Microsoft help page.
A Mailmerge field is used to accept data during a Mail Merge, and I don't believe that you are actually plan to do that.

I think we need to know your general objective with the project that has been the subject of a series of questions. Some of the questions seem to be attempts to get around Word design - so much so that it might be better to re-assess  the general approach.
mvp1985Author Commented:
Basically I am developing a word document that is used for evaluations of art and jewelery for which i use form fields and text describing what goes into the form field. I do this so I can quickly enter the text and then just advance with the tab key. Since every customer is different, I don't know ho many items I need to evaluate, so I use a macro, which runs at the exit of the last form field on the page, that enters a page break, and the same form fields and descriptions (in order for this to work, the macro unprotects the document, and later protects it again, so I can use tab again).  The last item I enter is the estimated price of the piece, but for legal purposes I also need to enter it in non-numerical form right beneath the numerical form. (so for example:

 Estimated price: $40.00
                                 Forty US Dollar

The mergefield you mentioned earlier works perfectly when I enter the number into the "amount" when I establish the meregield. But, since I have often hundreds over hundreds of these prices, I would love for a way that it is automated completely, and all I need to do is put the numerical price in, and the non-numerical amount is automatically entered below. So yes, I need to find a way to refer to the numeric value somehow. Any suggestions on how to refer automatically?
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Thank you,
Just got back from hospital visiting, so it is late here, but I'll try to look at it again in about 12 hours' time.
Eric was simply using a MERGEFIELD to demonstrate the use of the CardText switch. You should be able to use a REF field that refers to the FORMFIELD bookmark name. You will probably have to assign the field its name programatically.

The field code will look like this: { REF Text2 \*CardText }.

Note that CardText input is limited to six digits, so will not help if you are dealing with the Koh-i-Noor etc.
Eric FletcherCommented:
My last comment in your other question about adding a 3-digit sequential suffix (here) illustrates how the REF field works with a named bookmark.

Do also consider using the STYLEREF field code: if your form retains the original style formatting each time, you then won't need to assign a name programatically. (I haven't used forms enough to test this easily, but I do know that styles are retained through the mail merge process.)

And yes, Graham is correct; I was using the MERGEFIELD as an example of a field code that commonly uses the CardText switch.
What are you using as a data source? Would it be possible to create a field that would equal the value you're looking for? If say you were using Excel and your data started in A1, start a new field in B2 and have it equal A1. You can then copy and paste down.

Another possible option, you can get the next record using a NEXT field:

{NEXT} {MERGEFIELD "Amount" \*CardText}

You can use that on your first page and use {MERGEFIELD "Amount" \*CardText} on the second. You would just have to make sure your first record is blank, as it would not be picked up on the first page. Just a thought!

Eric FletcherCommented:
Have you been able to resolve your problems yet mvp1985?
mvp1985Author Commented:
Sorry for leaving the question abandoned for so long. I had a major move with my company, and the document was just not my priority anymore... But now I am back on working on it, and I made some big steps forward. I recreated the entire thing, and got it almost to the point were I want to be, but for the issue described in the question. Let me tell you what I have right now: I have a word document for evaluations of art pieces with descriptions and fields, and a macro that inserts an auto text when entering one of these fields (It just inserts more descriptions and fields at the bottom, so I can keep going when i am at the bottom of a page) That all works perfectly fine. Now, the only thing I did not get to work is this: I have an amount that is different for each different art piece, then I have a field (for now) in which I have to type the amount spelled out (so, for example: $40.00, forty USD) I am looking for a way to create the spelled amount automatically after I have populated the field with the digit amount. I know Eric and Graham have given some good suggestions above, but since I have changed the document completely, and I wasn’t able to figure it out based on your suggestions so far, I wanted to ask again for help in here. I have attached the file, so you can see what I have right now but for the macro. Thanks a lot in advance (and I still work on Word for Mac 2011).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Eric FletcherCommented:
I see there is a close request pending, but perhaps this screen snapshot of how I modified your template will help you sort it out.Annotated screen shots of template showing field codes and resultsAs noted, the value I used in my example (4,250) is presented as Cardtext in German because your template had the Language attribute set to German. Not being familiar with German, I will leave it to you to decide if the result (Viertausendzweihundertfünfzig) is in fact the correct presentation of the value!

Does this help?
mvp1985Author Commented:
Posted a similar question again here and linked new question to this one
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.