Reply
 
Thread Tools Display Modes
  #1   Report Post  
Saeed
 
Posts: n/a
Default Merge fields in word tables populate by a VBA query

Consider the following:

Create a word document which contains a table of 2 rows and 3 columns.
The first row has headers ("Boilerplate text")
The second row has mail merge fields in each cell, c1, c2, c3

Using VBA, I want to do the following:

Run a query
For each row returned
Loop

assign column values from the current row to c1, c2, c3

if more rows, add another row to the word table
End Loop

Now, I could have just one row and place all values for the columns in
the corresponding merge field and use the carriage return to put each
"row" on a different line, but the problem with this is lining up each
"row".

The reason for using VBA is so that this can be invoked from a Java tool
(thats how they do the current far simpler documents).



Saeed

ng_786
  #2   Report Post  
Suzanne S. Barnhill
 
Posts: n/a
Default

If I correctly understand what you're trying to do, it is simpler to do this
using a simple merge. If you create a single-row table containing your merge
fields and generate a catalog/directory merge, you will get one table row
for each data record. You then go back and add the table headings.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Saeed" wrote in message
...
Consider the following:

Create a word document which contains a table of 2 rows and 3 columns.
The first row has headers ("Boilerplate text")
The second row has mail merge fields in each cell, c1, c2, c3

Using VBA, I want to do the following:

Run a query
For each row returned
Loop

assign column values from the current row to c1, c2, c3

if more rows, add another row to the word table
End Loop

Now, I could have just one row and place all values for the columns in
the corresponding merge field and use the carriage return to put each
"row" on a different line, but the problem with this is lining up each
"row".

The reason for using VBA is so that this can be invoked from a Java tool
(thats how they do the current far simpler documents).



Saeed

ng_786


  #3   Report Post  
Saeed
 
Posts: n/a
Default

In message , Suzanne S. Barnhill
writes
If I correctly understand what you're trying to do, it is simpler to do this
using a simple merge. If you create a single-row table containing your merge
fields and generate a catalog/directory merge, you will get one table row
for each data record. You then go back and add the table headings.


Thanks Suzanne, two follow on questions

1. Can I invoke this catalog/directory merge via calls to a VBA module.

2. Can I have multiple tables of different types (rows and columns) each
with placeholders/merge fields for different queries being inlcuded in
the same document?

As an aside (and just an aside - I'm just trying to fit in with the way
things are done and get the job done) ,the reason why VBA is important
is because the client uses a Java tool that maps Java to VBA for
invoking an application that produces word documents with merged fields
from an Oracle database. New documents require that the designer produce
a VBA module that does the basic word, and then this can be easily
tramslate to the Java stuff for inclusion in the application.


Saeed

ng_786
  #4   Report Post  
Suzanne S. Barnhill
 
Posts: n/a
Default

I can't answer your questions, but I would suggest that more appropriate
forums would be microsoft.public.word.mailmerge.fields and any in the
microsoft.public.word.vba hierarchy.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Saeed" wrote in message
...
In message , Suzanne S. Barnhill
writes
If I correctly understand what you're trying to do, it is simpler to do

this
using a simple merge. If you create a single-row table containing your

merge
fields and generate a catalog/directory merge, you will get one table row
for each data record. You then go back and add the table headings.


Thanks Suzanne, two follow on questions

1. Can I invoke this catalog/directory merge via calls to a VBA module.

2. Can I have multiple tables of different types (rows and columns) each
with placeholders/merge fields for different queries being inlcuded in
the same document?

As an aside (and just an aside - I'm just trying to fit in with the way
things are done and get the job done) ,the reason why VBA is important
is because the client uses a Java tool that maps Java to VBA for
invoking an application that produces word documents with merged fields
from an Oracle database. New documents require that the designer produce
a VBA module that does the basic word, and then this can be easily
tramslate to the Java stuff for inclusion in the application.


Saeed

ng_786


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
In typing dates in Word, i.e. "January 12" how do you keep the "1. Carol Microsoft Word Help 2 January 12th 05 08:09 PM
word xp crashes after macros are recorded kharris0405 Microsoft Word Help 3 January 11th 05 10:50 PM
WP Delay Code - Word Equiv Mike G - Milw, WI Microsoft Word Help 6 January 10th 05 04:12 PM
mail merge problem - "Word found locked fields during the update.. zgaryt Tables 1 January 9th 05 01:04 PM
macro in word js Microsoft Word Help 1 December 28th 04 03:01 AM


All times are GMT +1. The time now is 04:18 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"