Macro to run according to a field

A

Anderflash

I want to do a fillin field in a .dot template. When the user creates a file
based on the template, the fillin activates (the normal behaviour), but I
want that according to the answer, execute a macro. If the user fills another
text, the field executes another macro.

Resuming: Is there a solution to the fields execute a macro, like
macrobutton, but activating not by double-click, but changing a value in the
field?
 
P

Peter Jamieson

Hi Anderflash,

It has been a while. Or maybe you are another Anderflash.

I haven't done this, but IMO there is only one viable way to get a macro to
run during a merge, and that's
a. use Word's MailMerge Events
b. use the MailMergeBeforeRecordMerge event to guide the processing.

As far as I can tell from a simple experiment, if you include a FILLIN field
in your Mail Merge Main Document, the user is prompted to enter the text
/before / the BeforeRecordMerge event fires. So All your BeforeRecordMerge
event code has to sdo is
a. get the text from the field (e.g. if you know it is the first field in
the Mail Merge Main Document, you could use Doc.Fields(1).Result.Text
b. execute your additional macro depending on the content of that text

Alternatively you might consider using an ASK field and eusing that VBA code
to look at the content of the bookmark named in the ASK, or simply issuing
an Inputbox call to get the text and do whatever you want with it.
 

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