VB6 and Word question

R

Robert

Hi,

I need some hints for the following problem.

I have a VB 6 application that needs to write data (text and image) to a
Ms-Word document (template)

So I created a Ms-Word document with some bookmarks. The VB App is able to
write the data to the Ms-Word document and save it with a new doc-name.
But.this works only for one page. How to deal with a multiple page document.

So the user of my application can create his/her own Word document
(template) and can choose every lay-out they wish as long as they insert the
obligatory fields.
My application uses this Word document (template), fills in the fields and
saves it with a new documentname.
But beforehand it's unknown how much pages the application needs. The
Microsoft Word document (template) contains only one page with the
obligatory fields.
So if the fields are filled, how to create the next page with the same
lay-out, .... read obligatory fields.

Is mail merge an option, and if so how to create such a Ms-Word document.

I hope you understand what i intend. My excuses but English is not my native
language.

Robert
 
P

Peter Jamieson

I think your main choices are:
a. do not use mail merge. Always start from the initial document, then for
each record in your data source
- copy/paste the initial document into an intermediate document
- insert your data and pictures into the intermediate document
- copy the intermediate document and append it to the output document
- clear or delte the intermediate document
b. use mail merge.
- create a new data source from the data in your VB6 program
- use OpenDataSource to connect the initial document to that data source
- perform the merge
- do any necessary postprocessing on the output document (which is the
ActiveDocument after the merge.

Before you use (b), you need to check that mailmerge is a viable process for
producing the kind of documents you want from the inputs you have. For
example, Mailmerge is not designed to process Parent/child tables to produce
things such as "one invoice with detail lines per customer". If you write
your own merge function, you may get a lot more control, but you have to do
a lot more work, e.g.
- decide how users should define where data should go in their documents
- validate that user markup
- do all the data insertion
- consider what to do about stuff such as headers/footers, other types of
field codes the users might enter (at what point should they be
executed/resolved)

Peter Jamieson
-
 
R

Robert

What about using AutoText. Create a new page after the last line and insert
AutoText (AutoText contains the whole page with bookmarks) ?

Robert
 
P

Peter Jamieson

Can do - jut make sure you clean up and don't leave the user with questions
to do with saving templates.

Peter Jamieson
 
R

Robert

Thanks Peter.

Peter Jamieson said:
I think your main choices are:
a. do not use mail merge. Always start from the initial document, then for
each record in your data source
- copy/paste the initial document into an intermediate document
- insert your data and pictures into the intermediate document
- copy the intermediate document and append it to the output document
- clear or delte the intermediate document
b. use mail merge.
- create a new data source from the data in your VB6 program
- use OpenDataSource to connect the initial document to that data source
- perform the merge
- do any necessary postprocessing on the output document (which is the
ActiveDocument after the merge.

Before you use (b), you need to check that mailmerge is a viable process
for producing the kind of documents you want from the inputs you have. For
example, Mailmerge is not designed to process Parent/child tables to
produce things such as "one invoice with detail lines per customer". If
you write your own merge function, you may get a lot more control, but you
have to do a lot more work, e.g.
- decide how users should define where data should go in their documents
- validate that user markup
- do all the data insertion
- consider what to do about stuff such as headers/footers, other types of
field codes the users might enter (at what point should they be
executed/resolved)

Peter Jamieson
-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top