So cool! Thank you for taking time to put together this video. In case anyone else gets the '5941' error, double-check that you have the column names exactly as described. Took me a while to figure out that I did not, in fact, have them correct!
This is an incredible tutorial!! Not only do you explain each step of the process, you also assume the user may not have certain features displayed, so you provide additional details throughout the process. I am an avid fan of what you're doing!
This is the single best instructional video I have ever come across. Hours and hours of manual work cut down to about 10 minutes. Thank you, thank you, thank you, thank you! 🎉 (Next stop: Mail Merge to Email with Custom Subject, Attachments, etc.)
I cannot explain in words how useful this video has been for me. This has saved me hours of work and heartache, thank you so much. And so beautifully explained, thank you.
OMG one of the most useful & helpful videos I've ever seen in my life! I was despairing this morning thinking about having to individually name 350 PDF files. And then discovered this! I can't thank you enough, not just for doing the video & supplying the macro, but for the fantastic way you explained it all & took us through what to do. A true leader & educator! THANK YOU!💥👋🙏🏅🏆
The level of gratitude I have for this is indescribable! Oh man, I had been working on this for countless hours and then this! I was initially like please don't make me download 3rd party apps, etc, etc. BUUUTTT THIS! Amazing. Thank you!
This is amazing. I have no experience of Macros, and this allowed me to do exactly what I needed to do, and has saved me so much time. The instruction was really clear and simple. Thank you very much!
Just what I was looking for, a million thank you's for your work and code, saving me so much time at work, and for being so generous in providing the mac code as well!
I can't even begin to tell you how helpful this has been. I've been searching the internet like crazy, and everything I found required me to download another piece of software (which I can't do as I don't have administrator rights on my work computer). I was able to sit back and watch my computer handle the approx 750 mail merged documents with ease. I can't even tell you how amazing this is. Thank you, thank you thank you. And an extra thank you for walking through the macro line by line so I knew there wasn't any "funny business" in there. LOL.
THANK YOU! THANK YOU! THANK YOU! You've saved me hours and hours of tedious work . Your instructions were clear, concise and thorough. I was skeptical that this would require almost as much effort as creating merge files one by one. In the end it was very simple to implement.
This is very well explained training! Break it down very nicely to understand and use it. Thank you and appreciate it. I would like to watch other training you have on youtube...Have a great day!
This was such a time-saver - I could almost cry! I did encounter the '5941' error, and I couldn't understand why since my column names matched the tutorial exactly. Then I realized my Excel file had reset to read-only mode. After using *Save As*, it reset the Visual Basic and deleted the macro. Once I restarted everything completely, it finally worked!
This is the coolest freaking thing ever. It's something that works so seamlessly that it feels like it should be a native feature in Word's merge mail. Awesome job. Thank you.
This is FANTASTIC!!! Just saved me hours of renaming individually!! THANKS SO MUCH!! Took me about 30mins to setup and now I'm off and running!! Thanks!
Thanks so much!! This code and video are life savers! As a non-coder, the explanations were well thought through and easy to follow. I appreciate you :)
Sir, your code will save many lives and many hours. This is exactly what I was looking for and you explained it exceptionally well. Thank you so much for your generosity!
Great video - thanks for sharing for free! I eliminated the single word file saving to only generate the PDFs with your in depth explanation, so thankful for this!
Hello, This is Leela from India. A big thank you for your help and support , Your a life saver :-) your easy step by step video , saved my life , I was struggling to save 100 letters , the instructions were so easy - even the copying of the macros from your website was easy.
Hi, the first word file was create and then it ran into an error Run-time error'5941': The requested number of the collection does not exist. Help! It's ok. I read some of your replies to others who had this issues. The column headers were not named correctly. Thank you for sharing the macro. It worked liked magic!!
I am so glad that this tutorial is still available! It saved me tons of work hours by allowing me merge and save countless docs to pdf files instead creating them one by one. Thank you for sharing your expertise and for making the process so simple.
It's like magic. Had to save & close both the letter & excel list first because i was getting the mentioned '5491' error. Also make sure you added columns are titled correctly. then after reopening and running it works. appreciate it - my team will now think i'm a genius.
This is the first time that I've ever posted a review. This tutorial is amazing. I followed the process expecting it to fail but it worked perfectly! Thank you for saving me hours of work. Very much appreciated!
Wow! Not only are this tutorial and resources really helpful, but also the neatness with which the macros codes are written is simply beautiful! Thank you!
You are a saint! I've been fighting with an older marco for over 3 hours trying to get it to work. Now I have what I need to finish those annoying tax receipt mail outs! Thank you!!
Imnoss, this is an incredible idea. You are amazing. Thank you! The step-by-step explanation makes life so easy. I am following and subscribing right-away.
Wow, you, sir, are an absolute genius. This is such an amazing time saver. Thank you for the step by step explanation and for making the macro available. Definitely a channel I will subscribe to.
This is an AMAZING tutorial. I have been watching youtube coding videos for years. This is by FAR the best one out there. Great job and thank you for making it. It is exactly what I needed, clearly described and will help me tremendously.
Fantastic! This macro just saved probably 20 hours of work trying to do this one by one. Thank you! The video is very well done, easy to follow and excellent teaching skills
I cannot thank you enough!! 1214 documents that I would have had to manually change the file name on and move to specific folders - you saved me SOOOO much time! Subscribing and going to watch all your videos and watch all the way through the ads so you can get credit for the watch time etc. - being a content creator, I know those things can help with income :)
@@Imnoss Do you have similar video but 1 file pdf has multiple pages. For example: I sent certificates to the employees of the same company, i only sent it to one PIC, and one file pdf containing multiple certificates.
Exactly what I was looking for! I have to make individualized reports for my students. 8 minutes of this video saved me an hour's slog I have to do several times a year. Thanks!
This was an amazing tutorial. I have to create hundreds of separate documents and our IT team blocked the previous word add-in for security concerns. This was so clear and easy and even better it worked perfectly the first time. A very well designed piece of VB code, thank you so much!
many videos i watched that mail merge just make all participants certificate in 1 file, this is realy helping me to make each pdf participants certificate
This was a lifesaver!! Thanks for sharing this video AND the code! I did end up having to use the numerical value associated with the file format in order to get it to work.
This seems incredible, but is not working for me. Can someone PLEASE help??? I am getting run time error 5941 "The requested member of collection does not exist." When I debug, this line is highlighted: singleDoc.SaveAs2 _ FileName:=masterDoc.MailMerge.DataSource.DataFields("DocFolderPath").Value & Application.PathSeparator & _ masterDoc.MailMerge.DataSource.DataFields("DocFileName").Value & ".docx", _ FileFormat:=wdFormatXMLDocument ' Save "singleDoc" as a word docx with the details provided in the DocFolderPath and DocFileName fields in the MailMerge data I am desperate.
Amazing solution using a macro within MS Word! And thanks a lot for sharing your knowledge in such a clear and detailed way with this wonderful tutorial. This is very useful indeed!
THANK YOUU!! I used a different tutorial that required you to write the macro as they didn't provide it. While it worked, it took a very long time to produce the results. This worked for my ~100 files. THANK YOU
Thank you so much for the clear explination and saving me a lot of work splitting up 120 documents into Word and PDF format. You are the hero of the day :-)!
This is beyond amazing ! At first , i thought its impossible , but i just thought that i should at least give it a try ! and trust me , i cannot thank you enough for this . This indeed was a life saver !
TNice tutorials was a fantastic beginner's guide, straight to the point, very clear. As a long-ti teacher I can tell you are quite apt at teacNice tutorialng!
Thank you for this wonderful tutorial. Not only is it a very effective macro, the way you have documented and explained it empowers the user to tweak it even more. Great job.
This is AWESOME! Thank you for having created this video and for making the macro available for copy/paste. It was really , really simple to implement and it worked right away. Thank you!!!
This is AWESOME! Million thanks Imnoss! I had a problem in the beginning, the data for naming the files contain characters that cannot be used for file names in windows. After I changed the naming system, it worked! Really impressed! Thanks for your generosity in sharing this. As the saying goes, may kindness begets kindness!
@@albertuserwinsusanto924 I'm sure my folder path is correct. Did you use this Code : Sub MailMergeToPdfBasic() ' Mark the start of the Subroutine (i.e. Macro) and name it "MailMergeToPdf" ' Macro created by Imnoss Ltd ' Please share freely while retaining attribution ' Last Updated 2021-05-03 Dim masterDoc As Document, singleDoc As Document, lastRecordNum As Integer ' Create variables ("Post-it Notes") for later use Set masterDoc = ActiveDocument ' Identify the ActiveDocument (foremost doc when Macro run) as "masterDoc" masterDoc.MailMerge.DataSource.ActiveRecord = wdLastRecord ' jump to the last active record (active = ticked in edit recipients) lastRecordNum = masterDoc.MailMerge.DataSource.ActiveRecord ' retrieve the record number of the last active record so we know when to stop masterDoc.MailMerge.DataSource.ActiveRecord = wdFirstRecord ' jump to the first active record (active = ticked in edit recipients) Do While lastRecordNum > 0 ' create a loop, lastRecordNum is used to end the loop by setting to zero (see below) masterDoc.MailMerge.Destination = wdSendToNewDocument ' Identify that we are creating a word docx (and no e.g. an email) masterDoc.MailMerge.DataSource.FirstRecord = masterDoc.MailMerge.DataSource.ActiveRecord ' Limit the selection to just one document by setting the start ... masterDoc.MailMerge.DataSource.LastRecord = masterDoc.MailMerge.DataSource.ActiveRecord ' ... and end points to the active record masterDoc.MailMerge.Execute False ' run the MailMerge based on the above settings (i.e. for one record) Set singleDoc = ActiveDocument ' Identify the ActiveDocument (foremost doc after running the MailMerge) as "singleDoc" singleDoc.SaveAs2 _ FileName:=masterDoc.MailMerge.DataSource.DataFields("DocFolderPath").Value & Application.PathSeparator & _ masterDoc.MailMerge.DataSource.DataFields("DocFileName").Value & ".docx", _ FileFormat:=wdFormatXMLDocument ' Save "singleDoc" as a word docx with the details provided in the DocFolderPath and DocFileName fields in the MailMerge data singleDoc.ExportAsFixedFormat _ OutputFileName:=masterDoc.MailMerge.DataSource.DataFields("PdfFolderPath").Value & Application.PathSeparator & _ masterDoc.MailMerge.DataSource.DataFields("PdfFileName").Value & ".pdf", _ ExportFormat:=wdExportFormatPDF ' Export "singleDoc" as a PDF with the details provided in the PdfFolderPath and PdfFileName fields in the MailMerge data singleDoc.Close False ' Close "singleDoc", the variable "singleDoc" can now be used for the next record when created If masterDoc.MailMerge.DataSource.ActiveRecord >= lastRecordNum Then ' test if we have just created a document for the last record lastRecordNum = 0 ' if so we set lastRecordNum to zero to indicate that the loop should end Else masterDoc.MailMerge.DataSource.ActiveRecord = wdNextRecord ' otherwise go to the next active record End If Loop ' loop back to the Do start End Sub ' Mark the end of the Subroutine
Holy moly. Thank you so much for this! I just had to clean up my spreadsheet for 5 variations of letters we had, but after that, it was so quick using your macro! Saved a lot of time. Thanks again!
hey can I ask what edit you made please? I ran the macro and it's only giving me the last doc and pdf. I've got about 60 documents to make but it's only producing the last one.
This was awesome!! Thank you. I could not get the VBA to work from the Word Mail Merge Document on-line, but I wrote the VBA from your TH-cam video and it worked like a charm. Thank you:)
Thanks so much for this tutorial, used it successfully today to help work through a problem that was otherwise going to require a lot of manual work to achieve
I actually shed a tear of joy watching this work the first time. Thank you so, so much!
Glad it helped!
So cool! Thank you for taking time to put together this video.
In case anyone else gets the '5941' error, double-check that you have the column names exactly as described. Took me a while to figure out that I did not, in fact, have them correct!
Thanks for the heads up about the '5941' error.
Aaaah thank you! i spent WAY too long stumped on this.
OMG, thank you!! The 5941 error was driving me crazy and like you I was sure I had it correct, but had spelt PDf instead of Pdf.
@@nzoutdoors1923 thanks for the spelling check post
But mine are correct and still is showing the error
This is an incredible tutorial!! Not only do you explain each step of the process, you also assume the user may not have certain features displayed, so you provide additional details throughout the process. I am an avid fan of what you're doing!
This is the single best instructional video I have ever come across. Hours and hours of manual work cut down to about 10 minutes. Thank you, thank you, thank you, thank you! 🎉 (Next stop: Mail Merge to Email with Custom Subject, Attachments, etc.)
I cannot explain in words how useful this video has been for me. This has saved me hours of work and heartache, thank you so much. And so beautifully explained, thank you.
OMG one of the most useful & helpful videos I've ever seen in my life! I was despairing this morning thinking about having to individually name 350 PDF files. And then discovered this! I can't thank you enough, not just for doing the video & supplying the macro, but for the fantastic way you explained it all & took us through what to do. A true leader & educator! THANK YOU!💥👋🙏🏅🏆
The level of gratitude I have for this is indescribable! Oh man, I had been working on this for countless hours and then this! I was initially like please don't make me download 3rd party apps, etc, etc. BUUUTTT THIS! Amazing. Thank you!
Need mail merge? BRILLIANT VIDEO! Step by step explanation makes this process super easy, even for someone like me with limited skills. Thank you!
This is amazing. I have no experience of Macros, and this allowed me to do exactly what I needed to do, and has saved me so much time. The instruction was really clear and simple. Thank you very much!
I've been using this for an awkward job for three years now and it has saved me and colleagues hours of labour - thank you so much!
Just what I was looking for, a million thank you's for your work and code, saving me so much time at work, and for being so generous in providing the mac code as well!
Good 23 mins of my life spent into learning a kickass thing. Crisp and to the point. Kudos!
thank you :)
Can you share VBA code here ?
@@sifatullah8071 , you need to write your own. :)
Paste once you're done, I can help with troubleshooting.
Thank you so much!!! This just saved me from separating 114 documents. You are a life saver!
Thank you, I hope it continues to be useful.
I can't even begin to tell you how helpful this has been. I've been searching the internet like crazy, and everything I found required me to download another piece of software (which I can't do as I don't have administrator rights on my work computer). I was able to sit back and watch my computer handle the approx 750 mail merged documents with ease. I can't even tell you how amazing this is. Thank you, thank you thank you. And an extra thank you for walking through the macro line by line so I knew there wasn't any "funny business" in there. LOL.
thank you :)
THANK YOU! THANK YOU! THANK YOU! You've saved me hours and hours of tedious work . Your instructions were clear, concise and thorough. I was skeptical that this would require almost as much effort as creating merge files one by one. In the end it was very simple to implement.
You're welcome.
This is very well explained training! Break it down very nicely to understand and use it. Thank you and appreciate it. I would like to watch other training you have on youtube...Have a great day!
You Sir are a hero. Cannot thank you enough for sharing your macro and taking the time to demonstrate it!
This was such a time-saver - I could almost cry! I did encounter the '5941' error, and I couldn't understand why since my column names matched the tutorial exactly. Then I realized my Excel file had reset to read-only mode. After using *Save As*, it reset the Visual Basic and deleted the macro. Once I restarted everything completely, it finally worked!
This is the coolest freaking thing ever. It's something that works so seamlessly that it feels like it should be a native feature in Word's merge mail. Awesome job. Thank you.
thank you :)
This is FANTASTIC!!! Just saved me hours of renaming individually!! THANKS SO MUCH!! Took me about 30mins to setup and now I'm off and running!! Thanks!
Honestly once explained it's fairly intuitive. Thank you for breaking it down so nicely for us newbies! Can't wait to play with the full version
I'm stunned about how robust and easy this is...thank you thank you!
Thanks so much!! This code and video are life savers! As a non-coder, the explanations were well thought through and easy to follow. I appreciate you :)
You're welcome!
Nice work! I have 30+ years of experience programming macros, and this code gave me excellent direction. Thanks!
Glad it helped!
Sir, your code will save many lives and many hours. This is exactly what I was looking for and you explained it exceptionally well. Thank you so much for your generosity!
You are most welcome
Great video - thanks for sharing for free! I eliminated the single word file saving to only generate the PDFs with your in depth explanation, so thankful for this!
Thank you so much! This save my day and the walkthrough is at a very good pace too! Not a second wasted! Brilliant work!
You've saved me from a nervous breakdown today! What a great tutorial.
OMG this just saved me from having to manually sort 600 files. ID KISS YOU IF I COULD.
+1
Me too available for kiss
Thank you! Data set is ~1500, and the test run yesterday was a success! Sincere thanks from Dallas, Texas.
You're welcome Kalyse, Great to hear!
Hello,
This is Leela from India. A big thank you for your help and support , Your a life saver :-) your easy step by step video , saved my life , I was struggling to save 100 letters , the instructions were so easy - even the copying of the macros from your website was easy.
Hi Leela, thank you so much, I really appreciate the positive feedback :)
Hi, the first word file was create and then it ran into an error Run-time error'5941': The requested number of the collection does not exist. Help! It's ok. I read some of your replies to others who had this issues. The column headers were not named correctly. Thank you for sharing the macro. It worked liked magic!!
FINALLY!! Thank you for this simple, straightforward, and time-saving solution!
I feel like a genius, I used a visual basic macro! Thank you for saving me from hours of tedium.
I am so glad that this tutorial is still available! It saved me tons of work hours by allowing me merge and save countless docs to pdf files instead creating them one by one. Thank you for sharing your expertise and for making the process so simple.
It's like magic. Had to save & close both the letter & excel list first because i was getting the mentioned '5491' error. Also make sure you added columns are titled correctly. then after reopening and running it works. appreciate it - my team will now think i'm a genius.
This is the first time that I've ever posted a review. This tutorial is amazing. I followed the process expecting it to fail but it worked perfectly! Thank you for saving me hours of work. Very much appreciated!
This is one of the best tech videos I have ever seen on TH-cam and exactly what I needed. Great teaching right here.
Wow! Not only are this tutorial and resources really helpful, but also the neatness with which the macros codes are written is simply beautiful! Thank you!
Glad it was helpful!
You are a saint! I've been fighting with an older marco for over 3 hours trying to get it to work. Now I have what I need to finish those annoying tax receipt mail outs! Thank you!!
Glad I could help
Imnoss, this is an incredible idea. You are amazing. Thank you! The step-by-step explanation makes life so easy. I am following and subscribing right-away.
Wow, you, sir, are an absolute genius. This is such an amazing time saver. Thank you for the step by step explanation and for making the macro available. Definitely a channel I will subscribe to.
You saved my life today, this video is amazing and my job is forever changed!!!!
You are most welcome.
This is an AMAZING tutorial. I have been watching youtube coding videos for years. This is by FAR the best one out there. Great job and thank you for making it. It is exactly what I needed, clearly described and will help me tremendously.
Thank You for sharing this !!!!!!!!! Save my day when creating multiple online certificates
Fantastic! This macro just saved probably 20 hours of work trying to do this one by one. Thank you! The video is very well done, easy to follow and excellent teaching skills
I cannot thank you enough!! 1214 documents that I would have had to manually change the file name on and move to specific folders - you saved me SOOOO much time! Subscribing and going to watch all your videos and watch all the way through the ads so you can get credit for the watch time etc. - being a content creator, I know those things can help with income :)
You're welcome!
@@Imnoss Do you have similar video but 1 file pdf has multiple pages. For example: I sent certificates to the employees of the same company, i only sent it to one PIC, and one file pdf containing multiple certificates.
THANK YOU MY BROTHER FROM ANOTHER COUNTRY AND ANOTHER FAMILY!!!
Exactly what I was looking for! I have to make individualized reports for my students. 8 minutes of this video saved me an hour's slog I have to do several times a year. Thanks!
One of the clearest tutorials i've seen. Nicely done!
Thank you Imnoss! Worked well. I liked and subscribed, you absolutely deserve it more followers!
Thanks for the sub!
WOW THIS IS AMAZING!! If only I had found this video years ago. My job makes me save hundreds of files one-by-one. Not anymore thanks to this macro!!
Saved me a lot of time, it is easy and simple to use. Thank you so much! I appreciate you sharing this, very grateful.
Hello, you did not get any error messages?
You just saved me from copy/paste super repetitive informations in multiples files for hours. Thank you so much
I did a mini dance when I ran the script! you saved me an enter day on mail merging 102 documents
You are a lifesaver. Thanks for sharing such valuable information for free.
i don't usually comment, but a thank you is not enough really. much appreciated
This was an amazing tutorial. I have to create hundreds of separate documents and our IT team blocked the previous word add-in for security concerns. This was so clear and easy and even better it worked perfectly the first time. A very well designed piece of VB code, thank you so much!
you are brilliant! Thank you! You just saved us having to manually name over 4000 documents for a mail merge!
Garrett Evans Wow thank you Garrett, you've made my day!
many videos i watched that mail merge just make all participants certificate in 1 file, this is realy helping me to make each pdf participants certificate
This was a lifesaver!! Thanks for sharing this video AND the code! I did end up having to use the numerical value associated with the file format in order to get it to work.
This video is a life-saver - it has genuinely helped me so much. Thank you
this is the greatest video ever uploaded to youtube
i had this setup by my colleague some years back, but now this video helped me to setup the same without my colleague helps.. thank you..
This seems incredible, but is not working for me. Can someone PLEASE help??? I am getting run time error 5941 "The requested member of collection does not exist." When I debug, this line is highlighted:
singleDoc.SaveAs2 _
FileName:=masterDoc.MailMerge.DataSource.DataFields("DocFolderPath").Value & Application.PathSeparator & _
masterDoc.MailMerge.DataSource.DataFields("DocFileName").Value & ".docx", _
FileFormat:=wdFormatXMLDocument ' Save "singleDoc" as a word docx with the details provided in the DocFolderPath and DocFileName fields in the MailMerge data
I am desperate.
GENIUS... absolute genius!!! You made my work day/week/month/year!!! OMG so awesome!!! Thank you!!!
Amazing solution using a macro within MS Word! And thanks a lot for sharing your knowledge in such a clear and detailed way with this wonderful tutorial. This is very useful indeed!
Excellent stuff! Your explanation of the macro-stuff and the entire process. Thanks for making this video.
This is amazing. Great solution, great clear, easy to understand video for the lay-man/person, great outcome! BRAVO!
Thank you very much!
THANK YOUU!! I used a different tutorial that required you to write the macro as they didn't provide it. While it worked, it took a very long time to produce the results. This worked for my ~100 files. THANK YOU
Thank you so much for the clear explination and saving me a lot of work splitting up 120 documents into Word and PDF format. You are the hero of the day :-)!
Wow! Thank you for this! I was able to figure it out and feel powerful!
Works like a charm! And I'm no macro expert at all! Thank you for sharing!
Thank you so much for taking the time to do this. It's brilliant!
This is magic, thanks!!!! As I have my Word configured in Spanish, I thought the code would not work... but it did!!!
You are an excellent instructor. I will stick with you.
Thank you very much, the world needs more people like you 😍
This is beyond amazing ! At first , i thought its impossible , but i just thought that i should at least give it a try ! and trust me , i cannot thank you enough for this .
This indeed was a life saver !
TNice tutorials was a fantastic beginner's guide, straight to the point, very clear. As a long-ti teacher I can tell you are quite apt at teacNice tutorialng!
thank you
Amazing!! Thank you - what a clear explanation for a complicated process. Well done! I have shared your TH-cam with all my colleagues.
I love this video it's the best and easiest way to do this process. I have shared this video a number of times!
Thank you for making my job easier. It worked like a charm.
Thank you so much for the tutorial and the code. I was subscribe you, I hope this channel grows bigger
I have no word for your excellent work. Thank you so much
Thanks a lot this video saves my hours of copy paste work .....this is what I am searching from last year .....thank you very much
Thank you for this wonderful tutorial. Not only is it a very effective macro, the way you have documented and explained it empowers the user to tweak it even more. Great job.
Thanks! Been looking for hours for a solution and with this macro it is done in a couple of minutes, huge life saver!
This is AWESOME! Thank you for having created this video and for making the macro available for copy/paste. It was really , really simple to implement and it worked right away. Thank you!!!
This is AWESOME! Million thanks Imnoss!
I had a problem in the beginning, the data for naming the files contain characters that cannot be used for file names in windows. After I changed the naming system, it worked! Really impressed! Thanks for your generosity in sharing this. As the saying goes, may kindness begets kindness!
Hello. Can you send me the text of the macro you used as the one provided on their website is not working
@@imentoukabri6726 it works. I didn't change the Macro code. Just make sure you make the folder path right.
@@albertuserwinsusanto924 I'm sure my folder path is correct. Did you use this Code : Sub MailMergeToPdfBasic() ' Mark the start of the Subroutine (i.e. Macro) and name it "MailMergeToPdf"
' Macro created by Imnoss Ltd
' Please share freely while retaining attribution
' Last Updated 2021-05-03
Dim masterDoc As Document, singleDoc As Document, lastRecordNum As Integer ' Create variables ("Post-it Notes") for later use
Set masterDoc = ActiveDocument ' Identify the ActiveDocument (foremost doc when Macro run) as "masterDoc"
masterDoc.MailMerge.DataSource.ActiveRecord = wdLastRecord ' jump to the last active record (active = ticked in edit recipients)
lastRecordNum = masterDoc.MailMerge.DataSource.ActiveRecord ' retrieve the record number of the last active record so we know when to stop
masterDoc.MailMerge.DataSource.ActiveRecord = wdFirstRecord ' jump to the first active record (active = ticked in edit recipients)
Do While lastRecordNum > 0 ' create a loop, lastRecordNum is used to end the loop by setting to zero (see below)
masterDoc.MailMerge.Destination = wdSendToNewDocument ' Identify that we are creating a word docx (and no e.g. an email)
masterDoc.MailMerge.DataSource.FirstRecord = masterDoc.MailMerge.DataSource.ActiveRecord ' Limit the selection to just one document by setting the start ...
masterDoc.MailMerge.DataSource.LastRecord = masterDoc.MailMerge.DataSource.ActiveRecord ' ... and end points to the active record
masterDoc.MailMerge.Execute False ' run the MailMerge based on the above settings (i.e. for one record)
Set singleDoc = ActiveDocument ' Identify the ActiveDocument (foremost doc after running the MailMerge) as "singleDoc"
singleDoc.SaveAs2 _
FileName:=masterDoc.MailMerge.DataSource.DataFields("DocFolderPath").Value & Application.PathSeparator & _
masterDoc.MailMerge.DataSource.DataFields("DocFileName").Value & ".docx", _
FileFormat:=wdFormatXMLDocument ' Save "singleDoc" as a word docx with the details provided in the DocFolderPath and DocFileName fields in the MailMerge data
singleDoc.ExportAsFixedFormat _
OutputFileName:=masterDoc.MailMerge.DataSource.DataFields("PdfFolderPath").Value & Application.PathSeparator & _
masterDoc.MailMerge.DataSource.DataFields("PdfFileName").Value & ".pdf", _
ExportFormat:=wdExportFormatPDF ' Export "singleDoc" as a PDF with the details provided in the PdfFolderPath and PdfFileName fields in the MailMerge data
singleDoc.Close False ' Close "singleDoc", the variable "singleDoc" can now be used for the next record when created
If masterDoc.MailMerge.DataSource.ActiveRecord >= lastRecordNum Then ' test if we have just created a document for the last record
lastRecordNum = 0 ' if so we set lastRecordNum to zero to indicate that the loop should end
Else
masterDoc.MailMerge.DataSource.ActiveRecord = wdNextRecord ' otherwise go to the next active record
End If
Loop ' loop back to the Do start
End Sub ' Mark the end of the Subroutine
Holy moly. Thank you so much for this! I just had to clean up my spreadsheet for 5 variations of letters we had, but after that, it was so quick using your macro! Saved a lot of time. Thanks again!
Seriously life changing. Thank you so much!
Code seen in the video worked for me....Thank You.... Liked and Subscribed...
I've seen that has actually explained it to in a concise way!
thanks!
I had to make an edit for some reason to the code but it actually did work. Thanks for this!
hey can I ask what edit you made please? I ran the macro and it's only giving me the last doc and pdf. I've got about 60 documents to make but it's only producing the last one.
This was awesome!! Thank you. I could not get the VBA to work from the Word Mail Merge Document on-line, but I wrote the VBA from your TH-cam video and it worked like a charm. Thank you:)
WOW, WOW, WOW..... THANK YOU! I really can't believe this worked for me, and I am thrilled with how much time I will save.
You literally saved me two days worth of work!!
Thanks so much for this tutorial, used it successfully today to help work through a problem that was otherwise going to require a lot of manual work to achieve
Wow! How cool is this?! Very! Thank you so much for creating the macro and all of the detailed instructions!
Thank you