#1
|
|||
|
|||
Merge group by key and split to individual pdf files
Hello everyone! With the help from few posts from these forums I have managed to almost completely solve my problem which is: I want to create certificates for users that attended different classes during the year and where each user's certificate would list all the classes he attended. I have data stored in attached xlsx file. Fields to group and merge data are in my main document (merge_main.docx). If I just run normal mail-merge in word, merged document gets created just fine, each page has certificate for one user and all classes he attended are listed. But then I added to the main document following macro to separate merged document to individual pdf files: Code:
Sub Merge_To_Individual_Files() ' ' Merges one record at a time to the "potrdila" sub-folder Application.ScreenUpdating = False Dim StrFolder As String, StrName As String, MainDoc As Document, i As Long, j As Long Set MainDoc = ActiveDocument With MainDoc StrFolder = .Path & "\potrdila\" With CreateObject("Scripting.FileSystemObject") If Not .FolderExists(StrFolder) Then .CreateFolder StrFolder End With For i = 1 To .MailMerge.DataSource.RecordCount With .MailMerge .Destination = wdSendToNewDocument .SuppressBlankLines = True With .DataSource .FirstRecord = i .LastRecord = i .ActiveRecord = i StrName = .DataFields("User") End With .Execute Pause:=False End With With ActiveDocument .SaveAs2 FileName:=StrFolder & StrName & ".pdf", FileFormat:=wdFormatPDF, AddToRecentFiles:=False .Close SaveChanges:=False End With Next i End With Application.ScreenUpdating = True End Sub Thanks. |
#2
|
||||
|
||||
This is a many to one mail merge - see Merge Many To One and the attached modified merge document and resulting files.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Quote:
|
#4
|
|||
|
|||
Quote:
Any advice with this? Thank you. |
#5
|
||||
|
||||
Ensure that PDF Creator is not set to automatically update. If you still have problems, contact me via my web site.
Unless you need the added security use the Office PDF option to create the files.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
Tags |
merge excel pdf |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Password protect individual files after merge | merkyfitz | Mail Merge | 4 | 03-10-2020 03:08 PM |
Mail Merge - split merged documents and rename each split document based on text in header | FuriousD | Word VBA | 1 | 05-12-2019 04:06 AM |
Mail merge to individual files, there's any kind of progress indicator | eduzs | Word VBA | 3 | 08-31-2018 08:46 PM |
Saving group of individual e-mails | gerryex | Outlook | 12 | 07-04-2016 12:45 PM |
Mail Merge To Individual PDF Files | iamrickdeans | Mail Merge | 1 | 01-15-2014 12:46 AM |