Merge information in a table with a template using VBA

C

Cissy

Hi - I have a project where I need to use VBA to merge names and other
information with a template using a user form.

My question is this - the books I have don't seem to go into this very well
- are there MVP articles or anything similar that I can use to learn about
this? Thanks for your help as always.
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?Q2lzc3k=?=,
I have a project where I need to use VBA to merge names and other
information with a template using a user form.
In what application (including version)? Could you please provide
more detail on what you need to do?

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 :)
 
C

Cissy

Hi Cindy - sorry about that, here are a few details.

I have created a letterhead template which I want to automate by using VBA
and merging to allow variables (Name, phone, fax, signature block) stored in
a Word table to be merged with the letterhead template. I want to use
bookmarks to mark the spot in the letterhead template where the variable
information needs to go.

I am using a list box to list names of employees, so when you choose a name
their variable info will be filled in, in the approriate place in the letter.

I am having problems specifically with linking the bookmark to the datafield.

I am playing with the following, but I know I need to reference the
bookmark. Your help is appreciated!.

sName = oDoc.MailMerge.DataSource.DataFields("Name")
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?Q2lzc3k=?=,
I have created a letterhead template which I want to automate by using VBA
and merging to allow variables (Name, phone, fax, signature block) stored in
a Word table to be merged with the letterhead template. I want to use
bookmarks to mark the spot in the letterhead template where the variable
information needs to go.

I am using a list box to list names of employees, so when you choose a name
their variable info will be filled in, in the approriate place in the letter.

I am having problems specifically with linking the bookmark to the datafield.

I am playing with the following, but I know I need to reference the
bookmark. Your help is appreciated!.

sName = oDoc.MailMerge.DataSource.DataFields("Name")
MailMerge and bookmarks are two completely different things. Generally, for
something like you describe, I wouldn't use mail merge fields, but bookmarks.
The basic syntax for dumping text into a bookmark is:

oDoc.Bookmarks("Name").Range.Text = "the text"

If you feel you may need to re-use the bookmark, you need to expand on this,
but that should get you started.

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 :)
 

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