![]() |
#1
|
|||
|
|||
![]()
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. |
Tags |
merge excel pdf |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
merkyfitz | Mail Merge | 4 | 03-10-2020 03:08 PM |
![]() |
FuriousD | Word VBA | 1 | 05-12-2019 04:06 AM |
![]() |
eduzs | Word VBA | 3 | 08-31-2018 08:46 PM |
![]() |
gerryex | Outlook | 12 | 07-04-2016 12:45 PM |
![]() |
iamrickdeans | Mail Merge | 1 | 01-15-2014 12:46 AM |