#1
|
|||
|
|||
Mail Merge keeping VBA Macro
I have created a mail merge document with ActiveX controls in it (radio buttons). The radio buttons, when selected, run some code and change text based on what has been selected. It all works fine in the merge template.
When I merge with a data source, the VBA code for the radio buttons does not stay with the output and I loose the functionality of the radio buttons. Is there a way of running a mail merge and retaining the VBA code in the output? |
#2
|
||||
|
||||
Word has no setting that would enable a mailmerge main document's VBA code automatically to be added to the output documents; it has to be done post-merge. That can be done manually or programmatically (but that becomes a potential problem if the code to do so is in the module you want to export, since the export code also gets exported).
However, there may be some more fundamental problems you will need to address. You refer to using the code to "change text based on what has been selected". That suggests you're either using field coding or bookmarks to manage the text changes. Neither of these is likely to survive the mailmerge (some fields do, but those that do probably don't offer the scope for what you're trying to achieve). Is there a reason your option selections can't be made part of the mailmerge (e.g. via field coding that tests various fields in the datasource, or use FILLIN or ASK fields as either the first record or each record is processed)?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thanks for the reply
I may be able to write some code to add this in post merge. I will look into that. I thought there may be an easier way built in by Microsoft. I have radio boxes within the document which changes text within a textbox so no need for field codes and addresses (as I figured they wouldn't survive the merge as you suggested). When I do the merge and paste the code into the output it does what I need it to do so this certainly is an option. I am not building this into the mail merge because I am creating a report for a client. The mail merge contains my intellectual property so I do not want them to have access to this. They will then conduct interviews and rate candidates (using the radio boxes) which then modifies an 'Overall Rating' further down the report. |
#4
|
||||
|
||||
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
I see where you are coming from but the nature of my field requires are lot of input and calculations to be made prior to generating the report. Most of this has been automated through a web system I have created. Each report is different as it is based on each candidates psych testing results.
Manually entering this could result in user error. I could create the report in excel however this isn't ideal. |
#6
|
||||
|
||||
I wasn't suggesting the base data be input manually. Instead of using a mailmerge you could do that with a macro.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
mail merge, vba |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mail Merge Macro | ch1325 | Word VBA | 2 | 06-08-2015 06:18 AM |
Mail Merge Macro | spc94 | Word VBA | 2 | 06-04-2015 07:06 AM |
Help Please: New VBA user trying to use a macro to split Mail Merge documents. Two Run-Time Error | zipit189 | Word VBA | 7 | 03-18-2015 01:13 PM |
Macro to loop through all cells in a table produced by a mail merge | elh52 | Word VBA | 4 | 08-31-2014 10:50 PM |
Word Doc Macro (mail Merge) | ajolson1964 | Word VBA | 1 | 05-10-2011 10:15 PM |