Click to See Complete Forum and Search --> : Need some help from the MS Word experts
jim.t
08-21-2001, 05:49 AM
I've got a Word document that merges MS Access data. I have no problems merging data with one set of selection criteria, but I need to bring in three separate groups of data (1's, 2's and 3's) from this database and place them in three different locations on this document. The database is made up of records coded with a space, 1,2 or 3. Based upon this code, the record will be placed in
one off three sections on this document (1=gold 2=silver 3=bronze). I've been able to accomplish this rather easily with one code, but therein lies the rub.
Surely, there must be a way to predefine the data locations on the document, and select data to the correct document location.
Appreciate the help and thanks. I'm pretty stumped. Any ideas would be appreciated, folks. Jim.
[This message has been edited by jim.t (edited 08-21-2001).]
qball
08-22-2001, 12:17 AM
wait a minute,
Is the problem that you can only merge one data source?
I'll try to find out and get back to you. This was pretty easy in the Word4.0 days, today, what a pain.
jim.t
08-22-2001, 03:53 AM
Yeah, it's only one data source, but I'm having to select three different types of data from it into three various locations of the document. I'm sure it's no big thing for someone who knows Word well, but obviously that's not me. http://www.sysopt.com/forum/smile.gif Thanks.
You may want to try conditional merging if you haven't looked at it already.
It can be accessed by the button next to the one that provides the mailmerge fields - "Insert Word Field"
There you will find the option to insert an If...Then...Else statement.
In the example below, the code would examine the record, and if the person scored a bronze, the phrase "Jim Smith came third" would appear.
If you wanted to place gold and silver elsewhere on the document, just position the editing caret where you want to place the phrase and use the "Insert Word Field" to add another conditional statement. You may find that creating text boxes (Insert->Text box) is the best way to control placement of this info.
To use mergefields within these statements, you can press ctrl+F9 to bring up a merge bracket pair. You can't just type {} from the keyboard, it wont work. Within that pair, type MERGEFIELD fieldname. The fieldname should correlate with those in your mailmerge data.
Also to see the code that you have inserted into your document (useful if placing within a sentence for example) Alt+F9 toggles the code on/off
{ IF { MERGEFIELD medal }= "bronze" "{MERGEFIELD Name} came third" "" }
Let me know if this is what you were looking for - I do loads of resonably complex conditional mailmerge stuff at work, so it's nice to share http://www.sysopt.com/forum/smile.gif
jim.t
08-22-2001, 07:30 AM
U-96, great info. That's exactly what I was looking for. I was able to get the mergefields setup, but didn't know you had to have a conditional "IF" with each replicat and not being able to use "Next" within the condition is a bummer.
Don't know too much about the text box thing, but is there any way to place two occurences per line, and how would I indicate that on my document?? When I finish with the mergefield statement, it's almost clear across the document. Then when I tested it it's only listing one per line, where I would like two.
Also,I was hoping to find some way to adjust for the data variance like another document example I have used:
<<Name>><<Next Record>><<Name>><<Next Record>
This will adjust for the number of occurences and keep adding to or shortening the document when needed. How can I allow for varying numbers everytime I run this? Do I have to setup x-number of mergefield fields?
Thanks alot, Jim.
[This message has been edited by jim.t (edited 08-22-2001).]
The way I understand it is that you have (for example) a list of sports day participants in some kind of data file.
You want to make a report which lists (in separate columns) those who won gold, silver or bronze, or nothing at all.
I had a crack at trying this in a table, but instead of neat lists, it merged leaving blank cells, and only one record per line in the correct column.
There is probably a smart way to achieve this with a creative use of NEXT, SKIPIF, IF THEN ELSE use or VBA stuff, but if you are in a rush (as I often am) then what may work is for you to use the INCLUDETEXT function within your main document.
This will allow you to insert the contents of any other document into your final copy.
Using the IF...THEN...ELSE example I gave above, you could make 4 separate basic mailmerge documents which present the data for each category. Merge each one to create
gold.doc
silver.doc
bronze.doc
unclassified.doc
At this stage you could just cut and paste the docs into your primary document, but you would have to do that every time something changed (if that is a consideration).
By using INCLUDETEXT you are linking to a document which can be refreshed simply by running the merge again and overwriting the original list document.
[LIST]
Make simple mergefiles for each category
Merge and save each one
Create your primary document (it must also be a mail merge file for {INCLUDETEXT} to work, but even if you link data to it, you don't have to use it!)
At the chosen points add
{ INCLUDETEXT "c:\\My Documents\\gold.doc } etc
Merge your primary document. All the lists should be added.
The INCLUDETEXT syntax can be very fussy, especially with filenames and paths. This page (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnovba00/html/MailMergePartII.asp) goes some way towards explaining it. http://www.sysopt.com/forum/smile.gif
Alternately, you may want to try creating a report in Access, I think this kind of stuff would be easier, but you might not have as much formatting control.
I use INCLUDETEXT for formatting overseas addresses in letters: I have each country style set up as a separate mergefile, using various elements of the address info from the data.
Where the address should be, I have a massive nested IF THEN ELSE statement with each country and the INCLUDETEXT link for the merge format to pull in and use. In this case, the data is applied after the INCLUDETEXT has done its stuff, so the application is a little simpler.
e.g.
{IF {MERGEFIELD country}="United Kingdom" "{INCLUDETEXT "c:\\ukaddress.doc}" "{INCLUDETEXT "c:\\usaaddress.doc}"}
usaaddress.doc just looks like:
{MERGEFIELD Line1}
{MERGEFIELD Line2}
{MERGEFIELD Line3}
{MERGEFIELD City}, {MERGEFIELD State} {MERGEFIELD Zip}
Thus the correct mergefields will be dropped in when the main document is merged http://www.sysopt.com/forum/smile.gif
jim.t
08-23-2001, 06:36 AM
Thanks a ton U-96. I owe you a big one. I'm trying to automate this document for work and was having a terrible time achieving it since either no one knew what I was talking about, was too busy to help, or just didn't want to help. At any rate, I'm gonna work on this until I get it right. Looks like I've got a plan now. http://www.sysopt.com/forum/smile.gif Thanks again, Jim.
no prob, I'm glad you found it useful. Not sure if it solves your challenge, but it gives another avenue to explore http://www.sysopt.com/forum/smile.gif
U-96
PS: A real cheat would be to sort your data by result, then name, merge one long list and then manually break and paste when you reach the end of each alphabet http://www.sysopt.com/forum/wink.gif
jim.t
08-23-2001, 07:24 AM
Been doing something like that...was trying to get away from all the hands-on cut & pasting. BTW, it seems in my tests regardless of which way I do it, if I use the If...Then...Else conditions, I'm still only gonna get one (1) record per line, and I need two and can't seem to manage it with the If statement. Back to the drawing board.
jim.t
08-24-2001, 06:19 AM
I was able to get the two columns up with this condition,
code:
(IF ( MERGEFIELD code)= 1) (MERGEFIELD name)(NEXT) (MERGEFIELD name) (NEXT)
(IF ( MERGEFIELD code)= 1) (MERGEFIELD name)(NEXT) (MERGEFIELD name) (NEXT)...etc.
but it doesn't stop with the gold...it just continues until the all the excel data is exhausted, instead of breaking at gold, silver and bronze. My guess is my condition is not complete, but I'm not sure where. I've tried several combinations to no avail. Thanks.
marccash
01-10-2002, 04:08 AM
I am part of a development team producing an HR & Payroll system. We have recently implemented multiple contracts and multiple position for a single person. This gives me a problem with the existing mail merge we have. All the data needed for mail merge has, up until now, been single data items (i.e. Surname, Forename1, …etc) however now I have the situation where a person can have multiple items (i.e. Surname, Forename1, Position1, Position2,……etc). I am investigating the possibility of trying to identify iterations and display the results within a single document.
I realise I could just dynamically include a header and data row for each multiple item a person has got but I have the problem that each person could, potentially, have a different number of current positions ranging none to n and that the document template field have to exist as a header in the data source.
I could also set the maximum number expected and output that number of header and data rows and hope the maximum is not exceeded. However multiple positions is just one of the multiple items I am trying to overcome and some of the others could be almost double figures.
I have also tried the following. But found it difficult to format and still include item before and after the iteration. And given that the customers have to have the ability to produce their own templates, I am not keen to complicate things any more than necessary.
(Here I have split up the data and produced a new record for each iteration)
{ Set Place1 { MERGEFIELD PersonId}}
{If{Place2}<>{Place1}"
ID: {MERGEFIELD PersonId} Name: MERGEFIELD Forename1} {MERGEFIELD Surname}
Job Title: {MERGEFIELD JobTitle}" "{MERGEFIELD JobTitle}
}{Set Place2 {MERGEFIELD PersonId}
Do you know of a solution. Or should I recommend the use of a conventional report and give up.
SysOpt.com
Copyright Internet.com Inc. All Rights Reserved.