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!
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!
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.
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!
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!
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.
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.
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.
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!
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.
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!
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.
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!
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 :)
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.
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!!
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!
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!!
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!
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!
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!
we got this to work after a few failed attempts and found that we were missing an = sign in one of the columns of the excel spread sheet this has changed our world in terms of workload. thanks guys.
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
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!
OMG I just danced & jumped around the office. I just did 585 construction log records in 45 minutes!!! Just splitting the files and renaming woukd have taken me a week. Thanks, Thanks Thanks
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.
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
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 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.
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.
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
hi, just want to say thank you. instead of subscribe adobe pdf pro version or take the risk to upload the confidential pdf to online pdf splitter, this just works!
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 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 !
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 :-)!
Works great. I was having a problem because I left the mail merge wizard open when I tried to execute the macro, but once I closed it this worked really well. Thanks
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!
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!!!
I’ve been using this over the last week to create and send out approximately 6000 letters and emails. The VB engine in this example, and in the example from your other video works absolutely perfectly and save me and my team are lots of time. The only issue that arose was with the wild cards used in the V look up. In some cases, the wild cards may need to be customised so that they can differentiate between individuals with the same name. What I had to do, was to include the date of birth as part of the wild card, so that there was more than just a name to select from.
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
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.
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!
I am so grateful for this video, it has saved me so much time and I was looking for a video on how to do custom file names for ages, so glad I found this! Massive thank you!
Hi Tarni, this is one of those crazy issues where so much time can be wasted. If you have any questions, please feel free to ask them here or via the website (imnoss.com/#contact).
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!
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.
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!
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!
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!
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.
Need mail merge? BRILLIANT VIDEO! Step by step explanation makes this process super easy, even for someone like me with limited skills. Thank you!
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.
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!
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.
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.
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 :)
You Sir are a hero. Cannot thank you enough for sharing your macro and taking the time to demonstrate it!
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!
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 :)
Nice work! I have 30+ years of experience programming macros, and this code gave me excellent direction. Thanks!
Glad it helped!
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.
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!
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 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.
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
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!
I feel like a genius, I used a visual basic macro! Thank you for saving me from hours of tedium.
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!
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 :)
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 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
OMG this just saved me from having to manually sort 600 files. ID KISS YOU IF I COULD.
+1
Me too available for kiss
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!
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!!
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!
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've saved me from a nervous breakdown today! What a great tutorial.
FINALLY!! Thank you for this simple, straightforward, and time-saving solution!
I'm stunned about how robust and easy this is...thank you thank you!
This is one of the best tech videos I have ever seen on UA-cam and exactly what I needed. Great teaching right here.
I did a mini dance when I ran the script! you saved me an enter day on mail merging 102 documents
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!
we got this to work after a few failed attempts and found that we were missing an = sign in one of the columns of the excel spread sheet this has changed our world in terms of workload. thanks guys.
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.
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
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!
THANK YOU MY BROTHER FROM ANOTHER COUNTRY AND ANOTHER FAMILY!!!
OMG I just danced & jumped around the office. I just did 585 construction log records in 45 minutes!!! Just splitting the files and renaming woukd have taken me a week. Thanks, Thanks Thanks
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.
You saved my life today, this video is amazing and my job is forever changed!!!!
You are most welcome.
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!!
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
One of the clearest tutorials i've seen. Nicely done!
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 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.
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..
i don't usually comment, but a thank you is not enough really. much appreciated
You just saved me from copy/paste super repetitive informations in multiples files for hours. Thank you so much
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.
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 the greatest video ever uploaded to youtube
you are brilliant! Thank you! You just saved us having to manually name over 4000 documents for a mail merge!
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
hi, just want to say thank you.
instead of subscribe adobe pdf pro version or take the risk to upload the confidential pdf to online pdf splitter, this just works!
thank you Jeff, if you have any requests or suggestions for other content, do let me know.
Thank you Imnoss! Worked well. I liked and subscribed, you absolutely deserve it more followers!
Thanks for the sub!
Thank you very much, the world needs more people like you 😍
Thank You for sharing this !!!!!!!!! Save my day when creating multiple online certificates
Thank you so much for taking the time to do this. It's brilliant!
I have no word for your excellent work. Thank you so 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.
Works like a charm! And I'm no macro expert at all! Thank you for sharing!
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 !
This video is a life-saver - it has genuinely helped me so much. 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 :-)!
Works great. I was having a problem because I left the mail merge wizard open when I tried to execute the macro, but once I closed it this worked really well. Thanks
You are a lifesaver. Thanks for sharing such valuable information for free.
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?
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!
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!!!
I’ve been using this over the last week to create and send out approximately 6000 letters and emails. The VB engine in this example, and in the example from your other video works absolutely perfectly and save me and my team are lots of time. The only issue that arose was with the wild cards used in the V look up. In some cases, the wild cards may need to be customised so that they can differentiate between individuals with the same name. What I had to do, was to include the date of birth as part of the wild card, so that there was more than just a name to select from.
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
You literally saved me two days worth of work!!
Wow! Thank you for this! I was able to figure it out and feel powerful!
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.
Excellent stuff! Your explanation of the macro-stuff and the entire process. Thanks for making this video.
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
I am so grateful for this video, it has saved me so much time and I was looking for a video on how to do custom file names for ages, so glad I found this! Massive thank you!
Hi Tarni, this is one of those crazy issues where so much time can be wasted. If you have any questions, please feel free to ask them here or via the website (imnoss.com/#contact).
This is magic, thanks!!!! As I have my Word configured in Spanish, I thought the code would not work... but it did!!!
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!
I love this video it's the best and easiest way to do this process. I have shared this video a number of times!
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.
GENIUS... absolute genius!!! You made my work day/week/month/year!!! OMG so awesome!!! Thank you!!!
THANK YOU SO MUCH! This was a lifesaver. My first time using macros and I was able to follow along and saved a huge amount of time.
Amazing!! Thank you - what a clear explanation for a complicated process. Well done! I have shared your UA-cam with all my colleagues.
Thank you for making my job easier. It worked like a charm.
This is an amazing tutorial Simon, your instructions are very clear. One of the best videos I have came across!
Great to hear!
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
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.
This is amazing. Great solution, great clear, easy to understand video for the lay-man/person, great outcome! BRAVO!
Thank you very much!
Thank you so much for the tutorial and the code. I was subscribe you, I hope this channel grows bigger
Wow! How cool is this?! Very! Thank you so much for creating the macro and all of the detailed instructions!
Thank you
Next level genius. This saved me so much time....