C
Charles Freeman
Word gurus, a bit of advice, please:
I am a database programmer with an app written in xBase++, a C-like
language. I know virtually nothing about Word, especially templates, macros,
and VBA.
I want to be able to (a) Edit mail merge templates and (b) perform mail
merges from within my database app by launching Word. I would like this to
work with any Word version from 2000 up. Here is my proposed architecture:
Edit:
1) Within the database app, the user selects a Word template file from a
list. .
2) The database app creates the data source as a .CSV file with the same
name as the .DOT template which contains one record, the merge field names.
3) Word is launched from the database app with the specified template as a
command line parameter. The user can edit and save the template.
Merge:
4) Within the database app, the user selects a Word template file from a
list. They also select the data record(s) to merge from within the internal
encrypted database.
5)* The database app creates a copy of the template, renaming it as a
temporary file name.
6) The database app "cooks" the data records, creating a .CSV file which
contains the header AND unencrypted data field(s) with the same temporary
file name root..
7)* The database app does a raw file edit of the template, finding the
original merge data source filename and replacing it with the new temporary
merge source filename.
8) Word is launched with the temporary template AND some sort of macro name
(which causes the merge to occur) as command line parameters.
* These steps are implemented because as far as I can tell Word embeds a
permanent data source name within the template itself, which cannot be
passed as a command line parameter to Word. I need to be able to run on a
network with multiple simultaneous access, so by doing it this way the users
don't bump one another.
I'm sure I'm not the first person down this merry path, and many of you will
have lots of helpful hints and suggestions for me on how I REALLY ought to
do it. ;-)
Many thanks,
Charlie
I am a database programmer with an app written in xBase++, a C-like
language. I know virtually nothing about Word, especially templates, macros,
and VBA.
I want to be able to (a) Edit mail merge templates and (b) perform mail
merges from within my database app by launching Word. I would like this to
work with any Word version from 2000 up. Here is my proposed architecture:
Edit:
1) Within the database app, the user selects a Word template file from a
list. .
2) The database app creates the data source as a .CSV file with the same
name as the .DOT template which contains one record, the merge field names.
3) Word is launched from the database app with the specified template as a
command line parameter. The user can edit and save the template.
Merge:
4) Within the database app, the user selects a Word template file from a
list. They also select the data record(s) to merge from within the internal
encrypted database.
5)* The database app creates a copy of the template, renaming it as a
temporary file name.
6) The database app "cooks" the data records, creating a .CSV file which
contains the header AND unencrypted data field(s) with the same temporary
file name root..
7)* The database app does a raw file edit of the template, finding the
original merge data source filename and replacing it with the new temporary
merge source filename.
8) Word is launched with the temporary template AND some sort of macro name
(which causes the merge to occur) as command line parameters.
* These steps are implemented because as far as I can tell Word embeds a
permanent data source name within the template itself, which cannot be
passed as a command line parameter to Word. I need to be able to run on a
network with multiple simultaneous access, so by doing it this way the users
don't bump one another.
I'm sure I'm not the first person down this merry path, and many of you will
have lots of helpful hints and suggestions for me on how I REALLY ought to
do it. ;-)
Many thanks,
Charlie