Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to put the results of a questionnaire in a Word document.

The questionnaire is completed using a web application, and the results are stored in a database. The letter needs to only include those questionnaire results that are deemed unsatisfactory, so the number of results varies. The results that need to be on the letter can be easily exported to an Excel spreadsheet. The table is something like this.

Question                   | Answer | Reason
====================================================
Is the project up to code? | No     | Plans missing.
Has payment been made?     | No     | Cheque returned, NSF.

How can I display the information as paragraphs inside of a Word document? Something like this.

Dear So-and-So,

The results of your questionnaire are as follows:

No - Is the project up to code?
 Plans Missing.

No - Has payment been made?
 Cheque returned, NSF.

Sincerely,

The Administration

When I use Mail Merge, I end up getting a separate document for each questionnaire item. I could insert in the <<NextRecord>> merge field, and duplicate the other merge fields, but still, multiple documents are generated, and unless there are the right number of copied fields, blank rows are made, or data is missed.

Is there a way to do a Mail Merge, inserting an unknown number of items into the same document? The result could either be a table or a series of paragraphs. Some sort of Mail Merge loop would be awesome!

share|improve this question
    
Ideally you'd want all questions for a given customer on the same row. Can you control the query that extracts the data from your database? –  Andi Mohr Apr 5 '13 at 17:49
    
@AndiMohr Yes, the query is in my control. If the questions, answers, and comments are all on the same row, is it possible to do the merge? –  dangowans Apr 5 '13 at 17:53
    
I think so yes - answer coming up. –  Andi Mohr Apr 5 '13 at 18:25
add comment

1 Answer

The trick is to get everything onto one row for each customer.

all on single row

The downside here is when you set up your mail merge in Word, you must enter every single field manually for (in your case) questions, answers and reasons.

mailmerge


So, the more work you do up front in, the less work you have to do in Word. If you can edit your SQL or Excel spreadsheet so that your question/answer/reason block is in a single cell, you can merge that single field all at once. CHAR(10) is your friend here!

all on single row, less fields


enter image description here


enter image description here

share|improve this answer
    
Very interesting idea. Too bad each question must be specified. Putting everything in one cell definitely makes it easier to manage. Thanks for the suggestion. –  dangowans Apr 5 '13 at 18:41
    
There's probably a way of using a macro in Word to automatically insert all your fields for the mail merge. Sadly that's beyond the borders of my superusing! –  Andi Mohr Apr 5 '13 at 18:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.