We help IT Professionals succeed at work.

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

mvp1985
mvp1985 asked
on
196 Views
Last Modified: 2015-04-20
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?
Comment
Watch Question

CERTIFIED EXPERT

Commented:
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.
GrahamSkanRetired
CERTIFIED EXPERT
Top Expert 2012

Commented:
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.

Author

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?
GrahamSkanRetired
CERTIFIED EXPERT
Top Expert 2012

Commented:
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.
GrahamSkanRetired
CERTIFIED EXPERT
Top Expert 2012

Commented:
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.
CERTIFIED EXPERT

Commented:
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.
CERTIFIED EXPERT

Commented:
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
CERTIFIED EXPERT

Commented:
Have you been able to resolve your problems yet mvp1985?
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
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?

Author

Commented:
Posted a similar question again here and linked new question to this one
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.