Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
[email protected] Zhuklinets@gmail.com is offline
external usenet poster
 
Posts: 2
Default Meging data from SQL Source - something like catalog, but not

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?
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Meging data from SQL Source - something like catalog, but not

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/mic...1c 46ceb8755e

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.

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

wrote in message
...
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?


  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
[email protected] Zhuklinets@gmail.com is offline
external usenet poster
 
Posts: 2
Default Meging data from SQL Source - something like catalog, but not

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:

http://groups.google.co.uk/group/mic...1c 46ceb8755e

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.

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

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Meging to a table with section breaks bristol Mailmerge 1 June 13th 07 12:11 PM
How to link a different Mailmerge header source and data source? Eleni_Malli Mailmerge 1 May 3rd 06 02:08 PM
DotNet Data Table as Mail Merge Data Source goraya Mailmerge 1 July 7th 05 09:51 AM
data in mail merge letter being cut off - data source field size? tgone Mailmerge 1 May 20th 05 02:10 PM
Merged data that is present in data source is missing in merge mbd_newjersey Mailmerge 1 December 17th 04 10:52 AM


All times are GMT +1. The time now is 05:06 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"