Tuesday, 3 April 2012

Word Mail Merge - a one page Quote with Line Items

Today I'm going to talk a bit about coding in Microsoft Word. If you didn't know you could do this there is a whole new world that's about to open up to you today, but if you already knew about this then hopefully I'll be showing you a thing or two that you may not have already seen.

In order to code in MSWord you have to open up the "fields" in which you can code. In a right click menu option this appears as "Toggle Fields." In order to see/access these "fields" you will need to press ALT + F9. If you open a new Word document and click ALT + F9 you won't see anything because there are no field codes on the page. You can add one however by pressing CTRL + F9.

So, a couple of key keystrokes we just learned:
ALT + F9 = Show Field Codes
CTRL + F9 = Add a new Field Code area

Once you know that you can look at all of Microsoft's templates and see what they do with Field Codes in MSWord to get their documents to look as nice as they do.

Now, the one specific point that I wanted to touch on was in regards to Quotes and line items. First just set up your document like any other form. Then when you get to the point in which you want to put the line items, you will need to insert a Field Code. This field code will check one of the parameters in the row of data, if the condition is met then it will insert the data from the row. If it does not it will move on to the next row and check it. Typically I like to check the Quantity field. If the Quantity is greater than 0 then they must be ordering it, so it must need to be on the quote.

So, your Field Code will look something like:

{ if {MERGEFIELD "Quote_Quantity"} > 0 "

< INSERT TABLE/DATA HERE >
"
}

We're almost done. We need to put an ending check on our document to make sure we don't print out the closing piece of our document over and over again, once for each line item on the quote. The key here is to check to see if the line item is the last item in the list.

It should look something like this:

{ if {MERGEFIELD "LastItem" } = "1" "

< CLOSING STATEMENTS/COMMENTS HERE >
"
}

Run through the mail merge and you should have documents that look similar to this:

Word Mail Merge

No comments:

Post a Comment