Avatar of Clif
Clif
Flag for United States of America asked on

Mail Merge with Form Data

Writing in Word 2010 for users who are running Word 2003

I have a Mail Merge document that's working well, pulling data out of the database and placing it where it needs to be.

Now I need to ask the user a couple of questions and place some text in certain places where it needs to be depending on the answer.  To that end, I have created a form with two combo boxes listing all the available choices and an OK button.  The user makes a selection, clicks OK and ...

Now what?

I know the values I want entered, but what's the code to move them from the btnOK_Click event to the doc file?

I was hoping the values would appear as variables that I could drop in like I am currently doing with mail merge fields.

How Do I?

TIA
Microsoft Word

Avatar of undefined
Last Comment
Clif

8/22/2022 - Mon
GrahamSkan

The main problem in adding data to a document is knowing where to put it.

One way is to use a bookmark:

ActiveDocument.Bookmarks("MyBookmark").Range.Text = cboQuestion1.Text
GrahamSkan

However I am not sure that the approach is suitable for use with mail merge.

Not that you can use an ASK field to allow the user to add some text to each record's output during a mail merge.
GrahamSkan

Oops.

"Not that you can ..."
should read:
"Note that you can ..."
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Clif

ASKER
I thought about using "Ask", but I need it to be in the form of a combobox (ie, a specific number of selections and no mis-spellings).  And, it looked like (from my research) that "Ask" was only available in Word 2010 (and possible 2007).

I tried the bookmark, and it does sort of work in that text is inserted in the document where I need it to go (just like my previous question, I am putting the data in a textbox on the document so that it doesn't move the existing text during an insert.  The biggest issue, though, is, that there is no way to "clear" the bookmark items so the user would have to close Word and restart it for each document.
ASKER CERTIFIED SOLUTION
GrahamSkan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Clif

ASKER
Perfect.  Thanks.