Code to enter Form Field Data.

R

Richard Gutery

Good day all. I've posted this in another NG and after several days rec'd
no response (and I don't generally post the same thing in different Ngs)
so here goes.

I have a situation whereby I'd like to be able to use a Macro or VBA code to
insert a data into MergeFields in a template in Word.

I've got the Template all done and thought of using the Macro recorder to do
a Mail Merge and extract the information from my Outlook contact list. It
kinda works (a few glitches). But, I can't seem to be able to do this
programmatically.

The Mail merge works (when using the Wizard), but I'd like to not have to
run the
wizard each and every time, and once I've run the Mail Merge wizard using a
Macro,
I can't seem to locate the VBA code.

Example of my template (in short) looks like so:

Company: Contact:
Phone: Fax: <<FaxTo>>

Beside each field, I'd like to be able to pick a the data from my
contacts (or other data soucre) to automatically fill in the form.

So I tried a different approach. Here's what I've gotten so far.
1) VB macro that displays a dialog box with the above text boxes (very
straight forward),
2) Fill in the VB form with the data,
3) I Need to be able to change a Word document Form Field based on some data
entered into the VB form,
4) All the MS online help (that I could find) suggests the below code will
do the trick (the quotes
are for outline purposes only and are not part of my code):

"ActiveDocument.FormFields("Faxto").Result = txtFaxNo"

All I get is "runtime error 5941".

Any ideas would be appreciated.

TX.
 
R

Richard Gutery

Thanks a lot Doug. That put me on the right track and it now works as I
expected and wanted.

I actually did try that link before, but I think I created Merge Fields
instead of Bookmarks. So that means one should read "All" the material
before touching the keyboard and mouse.

Cheers :)

Richard
 

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