Link to home
Start Free TrialLog in
Avatar of mvp1985
mvp1985

asked on

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?
Avatar of Eric Fletcher
Eric Fletcher
Flag of Canada image

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.
Avatar of mvp1985
mvp1985

ASKER

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?
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.
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!

Flyster
Have you been able to resolve your problems yet mvp1985?
ASKER CERTIFIED SOLUTION
Avatar of mvp1985
mvp1985

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.User generated imageAs 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?
Avatar of mvp1985

ASKER

Posted a similar question again here and linked new question to this one