View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Macro to run according to a field

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.

--
Peter Jamieson
http://tips.pjmsn.me.uk

"Anderflash" wrote in message
...
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?