Solved

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

Posted on 2014-11-27
11
26 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?
0
Comment
Question by:mvp1985
  • 4
  • 3
  • 3
  • +1
11 Comments
 
LVL 21

Expert Comment

by:EricFletcher
Comment Utility
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.
0
 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
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.
0
 

Author Comment

by:mvp1985
Comment Utility
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?
0
 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
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.
0
 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
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.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 21

Expert Comment

by:EricFletcher
Comment Utility
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.
0
 
LVL 22

Expert Comment

by:Flyster
Comment Utility
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
0
 
LVL 21

Expert Comment

by:EricFletcher
Comment Utility
Have you been able to resolve your problems yet mvp1985?
0
 

Accepted Solution

by:
mvp1985 earned 0 total points
Comment Utility
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).
Template.docx
0
 
LVL 21

Expert Comment

by:EricFletcher
Comment Utility
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?
0
 

Author Closing Comment

by:mvp1985
Comment Utility
Posted a similar question again here and linked new question to this one
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now