Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-25-2019, 07:32 PM
QCaesar QCaesar is offline Sending Mailmerge Output to Individual Files Windows 10 Sending Mailmerge Output to Individual Files Office 2013
Novice
Sending Mailmerge Output to Individual Files
 
Join Date: Jul 2019
Posts: 3
QCaesar is on a distinguished road
Question Sending Mailmerge Output to Individual Files


I am trying to use this macro to save the output files to pdf however it is not working. I am not receiving any error message or anything. Just nothing. Here is the formula.

Code:
Sub Merge_To_Individual_Files()
' Sourced from: https://www.msofficeforums.com/mail-...ps-tricks.html
Application.ScreenUpdating = False
Dim StrFolder As String, StrName As String, MainDoc As Document, i As Long, j As Long
Const StrNoChr As String = """*./\:?|"
Set MainDoc = ActiveDocument
With MainDoc
  StrFolder = .Path & Application.PathSeparator
  For i = 1 To .MailMerge.DataSource.RecordCount
    With .MailMerge
      .Destination = wdSendToNewDocument
      .SuppressBlankLines = True
      With .DataSource
        .FirstRecord = i
        .LastRecord = i
        .ActiveRecord = i
        If Trim(.DataFields("Name")) = "" Then Exit For
        'StrFolder = .DataFields("Folder") & Application.PathSeparator
        StrName = .DataFields("EMail") & "-STUDENT NAME-" & .DataFields("Student_Name") & "-SHAQ-TO-SCHOOL TICKET"
      End With
      .Execute Pause:=False
      If Err.Number = 5631 Then
        Err.Clear
        GoTo NextRecord
      End If
    End With
      For j = 1 To Len(StrNoChr)
        StrName = Replace(StrName, Mid(StrNoChr, j, 1), "_")
      Next
    StrName = Trim(StrName)
    With ActiveDocument
      .SaveAs FileName:=StrFolder & StrName & ".pdf", FileFormat:=wdFormatPDF, AddToRecentFiles:=False
      .Close SaveChanges:=False
    End With
NextRecord:
  Next i
End With
Application.ScreenUpdating = True
End Sub

Last edited by macropod; 07-25-2019 at 07:38 PM. Reason: Added code tags
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending Mailmerge Output to Individual Files Send Mailmerge Output to Individual Files - Help with VBA plupton Mail Merge 2 12-24-2019 07:18 AM
Sending Mailmerge Output to Individual Files Mailmerge to Individual Files Creating Extra Pages cmt11 Mail Merge 2 04-21-2019 09:32 AM
Sending Mailmerge Output to Individual Files Send Mailmerge Output to Individual Files - Help Needed sunrise06 Mail Merge 4 12-22-2018 07:56 PM
Sending Mailmerge Output to Individual Files Save mailmerge records as individual word files using VBA beefcake2000 Word VBA 3 11-10-2017 09:55 PM
Sending Mailmerge Output to Individual Files Send Mailmerge Output to Individual Files - troubleshooting help mxk372 Mail Merge 1 07-06-2017 03:49 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:54 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft