Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-02-2015, 06:52 PM
Piney Piney is offline Mail Merge keeping VBA Macro Windows 7 64bit Mail Merge keeping VBA Macro Office 2007
Novice
Mail Merge keeping VBA Macro
 
Join Date: Aug 2015
Posts: 3
Piney is on a distinguished road
Default 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?
Reply With Quote
  #2  
Old 08-02-2015, 10:00 PM
macropod's Avatar
macropod macropod is online now Mail Merge keeping VBA Macro Windows 7 64bit Mail Merge keeping VBA Macro Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 08-02-2015, 10:29 PM
Piney Piney is offline Mail Merge keeping VBA Macro Windows 7 64bit Mail Merge keeping VBA Macro Office 2007
Novice
Mail Merge keeping VBA Macro
 
Join Date: Aug 2015
Posts: 3
Piney is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 08-02-2015, 10:41 PM
macropod's Avatar
macropod macropod is online now Mail Merge keeping VBA Macro Windows 7 64bit Mail Merge keeping VBA Macro Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Piney View Post
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.
In which case, why use mailmerge at all? It seems to me the entire process could be driven from a macro-template to populate the document, which could use formfields and such other fields as you need to calculate the ratings. That avoids the problem of your clients potentially having macros disabled (deliberately or otherwise) when they use the form.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 08-02-2015, 11:57 PM
Piney Piney is offline Mail Merge keeping VBA Macro Windows 7 64bit Mail Merge keeping VBA Macro Office 2007
Novice
Mail Merge keeping VBA Macro
 
Join Date: Aug 2015
Posts: 3
Piney is on a distinguished road
Default

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.
Reply With Quote
  #6  
Old 08-03-2015, 04:12 PM
macropod's Avatar
macropod macropod is online now Mail Merge keeping VBA Macro Windows 7 64bit Mail Merge keeping VBA Macro Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply

Tags
mail merge, vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail Merge keeping VBA Macro 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
Mail Merge keeping VBA Macro Word Doc Macro (mail Merge) ajolson1964 Word VBA 1 05-10-2011 10:15 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:01 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft