Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / November 2007

Tip: Looking for answers? Try searching our database.

Meging data from SQL Source - something like catalog, but not

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Zhuklinets@gmail.com - 22 Nov 2007 15:32 GMT
Hello. I need to merge some data from MS SQL with word template.
There are many lines - some fields are unique, some not. I.e.
Table:
ID FirstName LastName Number Language
1   Mary           Ann          1           Lang1
1   Mary           Ann          1           Lang2
1   Mary           Ann          1           Lang3
2   Peter         Stas           1          Lang1
2   Peter         Stas           1          Lang2
3   Bob           Marley        1          Lang1

Document must be like:

Employee Mary Ann with number 1 knows
<there is a table>
--------------
Lang1   |
-------------
Lang2   |
-------------
Lang3   |
---------

And other docs with other people.

I've found article http://support.microsoft.com/kb/211303, but I can't
even make work correctly their example -
in doc was page breaks, city appears twice at first iteration... And I
can't insert here my code from document also:(.

Could anyone helps to solve that problem with complex merging?
Peter Jamieson - 23 Nov 2007 02:01 GMT
Although the data is rather different and the document is quite complex,
have a look at the following conversation:

http://groups.google.co.uk/group/microsoft.public.word.mailmerge.fields/browse_f
rm/thread/326a090cc452ec7d/a82d1c46ceb8755e?lnk=st&q=jamieson+mergeseq#a82d1c46c
eb8755e


The sample files are, I think still at

http://suzleigh.com/MERGE.aspx

However, inserting a Word /table/ in the way that you suggest cannot really
be done using this technique because when you mix fields and table rows,
there will always be gaps between table rows in the output, and they are not
particulalry easy to remove. There is another approach which uses a DATABASE
field with a "coordinated" query to insert the relevant rows (e.g.

{ DATABASE \d "whatever" \c "The conection info. for your database" \s
"SELECT * FROM myview WHERE myview.ID = '{ MERGEFIELD ID }' }

). But unfortunately
a. you have very limited control over the appearance of the output when you
do that.
b. You can't, for example, control the formatting of the data in each
column separately, and the table width may change from page to page
depending on the amount of space the output occupies.
c. using \*MERGEFORMAT in the DATABASE field to retain formatting that you
apply to the table might seem like a sensible thing to try, but IME it
breaks down quite rapidly, e.g. at a page break.

However, if you combined that approach with some VBA that either
postprocessed the output from the merge, or used Word's MailMerge events,
you might be able to achieve the formatting you need.

Signature

Peter Jamieson
http://tips.pjmsn.me.uk

> Hello. I need to merge some data from MS SQL with word template.
> There are many lines - some fields are unique, some not. I.e.
[quoted text clipped - 27 lines]
>
> Could anyone helps to solve that problem with complex merging?
Zhuklinets@gmail.com - 27 Nov 2007 13:44 GMT
Good. I've decided to do it using VBA - it gives me full control over
the document with rich opportunities. Also, I need to do something
like this with excel templates...

Thank for ideas!

Peter Jamieson:
> Although the data is rather different and the document is quite complex,
> have a look at the following conversation:
[quoted text clipped - 31 lines]
> Peter Jamieson
> http://tips.pjmsn.me.uk
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.