Microsoft Office Forums VBA code not in module of new document produced by mail merge

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-10-2018, 03:26 AM
MP1989 MP1989 is offline VBA code not in module of new document produced by mail merge Windows 10 VBA code not in module of new document produced by mail merge Office 2010 64bit
Novice
VBA code not in module of new document produced by mail merge
 
Join Date: Jun 2018
Posts: 9
MP1989 is on a distinguished road
Default VBA code not in module of new document produced by mail merge

Hi all,

Microsoft Word - Mail merge / VBA question

I have set up a document to perform mail merge, which works fine. However once I run the mail merge the VBA code that I have built into the document doesn't transfer across into the new document prepared by the mail merge. Does anyone have any ideas if this can be done?

To give you more information the VBA code works fine in the original document, but after performing mail merge the code is not in the module of the new document.

I have tried adding this to my normal document module and it worked on the new document produced by mail merge, however I need this to be available to other people and so need a solution built into the document.

Don't know if its possible to have a code that copies the current code into the normal module or if there is a better way to do this?



Thanks for your help in advance!
Reply With Quote
  #2  
Old 09-10-2018, 05:03 AM
macropod's Avatar
macropod macropod is offline VBA code not in module of new document produced by mail merge Windows 7 64bit VBA code not in module of new document produced by mail merge Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

That is to be expected. Your code should be stored in the template your mailmerge main document is based on. That way, the code will be available to both the mailmerge main document and any output documents you produce from it.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 09-10-2018, 07:29 AM
MP1989 MP1989 is offline VBA code not in module of new document produced by mail merge Windows 10 VBA code not in module of new document produced by mail merge Office 2010 64bit
Novice
VBA code not in module of new document produced by mail merge
 
Join Date: Jun 2018
Posts: 9
MP1989 is on a distinguished road
Default

Hi Paul,

Thanks for the response.

By based on the template do you mean the normal template? I have tried this but then if colleagues open it on their computer this doesn't work.

I have made the VBA starting with "Private Sub Document" is this the issue?

thanks,
Reply With Quote
  #4  
Old 09-10-2018, 02:16 PM
macropod's Avatar
macropod macropod is offline VBA code not in module of new document produced by mail merge Windows 7 64bit VBA code not in module of new document produced by mail merge Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

In that case, you should create a suitable template and save it in a location your colleagues do have access to, then attach that template to your mailmerge main document.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Code to automatically complete mail-merge document for upto 200 recipients etcib Excel Programming 3 04-23-2018 02:23 PM
VBA code not in module of new document produced by mail merge Mail Merge Code Issue Andrewwill Mail Merge 6 01-06-2018 10:25 PM
VBA code not in module of new document produced by mail merge Inserting code line in Word Module mihnea96 Excel Programming 2 08-15-2017 04:57 AM
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 Field Code Manipulation macjnr Mail Merge 0 09-10-2009 11:37 AM


All times are GMT -7. The time now is 08:28 AM.


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