Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-06-2023, 12:51 PM
maw444 maw444 is offline run aVBA Macro Windows 10 run aVBA Macro Office 2019
Advanced Beginner
run aVBA Macro
 
Join Date: Feb 2021
Posts: 35
maw444 is on a distinguished road
Default run aVBA Macro


I have a document in which I have also a VBA Macro defined.

How can I get it to run automatically when a user does a Mail Merge?
Reply With Quote
  #2  
Old 01-06-2023, 05:34 PM
macropod's Avatar
macropod macropod is offline run aVBA Macro Windows 10 run aVBA Macro Office 2016
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

You might start by taking a look at:
https://www.msofficeforums.com/137121-post2.html
https://www.msofficeforums.com/170431-post6.html
https://www.msofficeforums.com/151721-post27.html
https://www.msofficeforums.com/100294-post17.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 01-07-2023, 02:13 AM
maw444 maw444 is offline run aVBA Macro Windows 10 run aVBA Macro Office 2019
Advanced Beginner
run aVBA Macro
 
Join Date: Feb 2021
Posts: 35
maw444 is on a distinguished road
Default

Thank you but I don't think i was clear what the issue is.

My external program starts a mail merge using Word.

When I was trying to do was to insert a code to change the formatting in the created document before it closes the merger routine.

I have written the code - it's how I get it to run on the created document that's the problem.

If I can make it the last thing that happens before it closes the mail merger that would be great
Reply With Quote
  #4  
Old 01-08-2023, 08:33 PM
Guessed's Avatar
Guessed Guessed is offline run aVBA Macro Windows 10 run aVBA Macro Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

You can name a macro to get it to run with an event that you know has to happen after your merge. An example is the Document_Close event
See Document.Close event (Word) | Microsoft Learn
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Remove Paras with Line Spac 6; Macro to Convert Paragraphs to Outline Numbered venganewt Word VBA 0 01-25-2022 06:28 PM
run aVBA Macro Footnote extraction macro [Why is this macro so slow? / anyway to make it faster?] Le_Blanc Word VBA 10 03-22-2021 11:38 AM
Spell check macro within macro button field doesn't work in one document samuelle Word VBA 0 07-20-2016 02:27 AM
run aVBA Macro Macro Question: Need help making a macro to highlight the first word in every sentence LadyAna Word 1 12-06-2014 10:39 PM
custom icon, undo/redo for macro, permanent macro Rapier Excel 0 08-05-2013 06:30 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:04 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