Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
 
Posts: n/a
Default Form fields versus mail merge fields

Hi,
I have an application which needs to communicate with MS Word to
generate documents.
Typically my application will want to generate 1 document at a time.
The user will select a template name and then choose to build a
document.
My application then has the responsibility of populating the document
with values.
I have created document templates in MS Word which contain form fields.
I have given my fields bookmark names.
I am using COM automation to communicate with Word and I am using
WordBasic interface to call the functions I need performed.
I can start Word and give it a template to open. I then ask it for all
the bookmark names.
I then cycle through each bookmark and populate it via doing a 'GoTo'
bookmark followed by an 'Insert'. It all seems to be working.
Questions
1) what about using mail merge fields. Can I achieve the same thing
using a mail merge ? Is it any easier ? Do I need to build a data
source file containing all my data and then do a mail merge ?
2) the WordBasic interface is now old technology. What is a more modern
approach to achieving my requirements ?
3) In general what is the best approach to having my application
generate Word documents for my users ?

Thanks

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Charles Kenyon
 
Posts: n/a
Default Form fields versus mail merge fields

Mailmerge would almost certainly be easier. Formfields are not meant to be
used the way you are using them. You could use regular bookmarks as easily
without the formfields.

I regularly produce mailmerges with just one record being used. You would
build a data source, which can hold multiple records. So long as you build
it with each record having a unique identifier, you should be able to
automate inserting a particular record fairly easily. (Says one who has not
done this!)

http://word.mvps.org/FAQs/MailMerge/...AMailMerge.htm
http://word.mvps.org/FAQs/MailMerge/...DataSource.htm

Much more at http://word.mvps.org/FAQs/Mailmerge.htm and
http://addbalance.com/word/wordwebre....htm#mailmerge
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.


wrote in message
oups.com...
Hi,
I have an application which needs to communicate with MS Word to
generate documents.
Typically my application will want to generate 1 document at a time.
The user will select a template name and then choose to build a
document.
My application then has the responsibility of populating the document
with values.
I have created document templates in MS Word which contain form fields.
I have given my fields bookmark names.
I am using COM automation to communicate with Word and I am using
WordBasic interface to call the functions I need performed.
I can start Word and give it a template to open. I then ask it for all
the bookmark names.
I then cycle through each bookmark and populate it via doing a 'GoTo'
bookmark followed by an 'Insert'. It all seems to be working.
Questions
1) what about using mail merge fields. Can I achieve the same thing
using a mail merge ? Is it any easier ? Do I need to build a data
source file containing all my data and then do a mail merge ?
2) the WordBasic interface is now old technology. What is a more modern
approach to achieving my requirements ?
3) In general what is the best approach to having my application
generate Word documents for my users ?

Thanks



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Cindy M -WordMVP-
 
Posts: n/a
Default Form fields versus mail merge fields

Hi ,

Generally, I'd use bookmarks (Insert/Bookmark) rather than form fields if
the user isn't expected to type into the form fields.

Instead of WordBasic, these days VBA is used. And I recommend it as
WordBasic is slowly beginning to come apart at the seams when the
technology behind the Word application has changed radially enough.

To write data into a particular Word bookmark:
Dim doc as Word.Document
Dim rng as Word.Range

Set doc = documents.Add(Template:="Path to *.dot file")
If doc.Bookmarks.Exists("Name") Then
Set rng = doc.Bookmarks("Name").Range
rng.Text = "My data"
End If

Note: if required, the bookmark can be recreated after inserting the data
doc.Bookmarks.Add Range:=rng, Name:="Name"

Using GoTo to jump to bookmarks is no longer necessary. NOT doing so will
be faster.

Personally, I would NOT try to use mail merge for this. The reasons:
- you'd need to build the data source from your data, save that to file
- then make sure the mail merge document links up to it, and because
in modern versions of Word, if you use automation to open a mail merge
document the data source will be unlinked - you have no choice but to
link up using code
- then you have to take care of executing the merge and making sure
you save/close the correct documents.

By the time you've done all this (using VBA, which you'd have to do as
mail merge has changed appreciably since the WordBasic days), you'll have
spent more time coding, and have a slower result, than polishing up your
existing bookmark code :-)

I have an application which needs to communicate with MS Word to
generate documents.
Typically my application will want to generate 1 document at a time.
The user will select a template name and then choose to build a
document.
My application then has the responsibility of populating the document
with values.
I have created document templates in MS Word which contain form fields.
I have given my fields bookmark names.
I am using COM automation to communicate with Word and I am using
WordBasic interface to call the functions I need performed.
I can start Word and give it a template to open. I then ask it for all
the bookmark names.
I then cycle through each bookmark and populate it via doing a 'GoTo'
bookmark followed by an 'Insert'. It all seems to be working.
Questions
1) what about using mail merge fields. Can I achieve the same thing
using a mail merge ? Is it any easier ? Do I need to build a data
source file containing all my data and then do a mail merge ?
2) the WordBasic interface is now old technology. What is a more modern
approach to achieving my requirements ?
3) In general what is the best approach to having my application
generate Word documents for my users ?


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)

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
Mail merge - use specific fields in the contacts folder to customi Rachelle Mailmerge 1 November 29th 05 01:49 PM
How to use mail merge to send out a form with blank text fields? Gwendolyn Mailmerge 1 November 17th 05 05:16 AM
How can I protect a form and still have mail merge? Beth Mailmerge 1 March 12th 05 04:41 AM
Empty Mail Merge Fields Meggan Microsoft Word Help 1 January 13th 05 05:22 AM
Empty Mail Merge Fields Meggan Microsoft Word Help 0 January 13th 05 12:43 AM


All times are GMT +1. The time now is 11:24 PM.

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"