View Single Post
 
Old 04-11-2024, 03:52 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Can you adapt this looping code to fit your requirements? Start by testing it by itself before you start adding your extra code. It appears you have code included in your sample which may not be required with this approach.
Code:
Public Sub Merge_To_Individual_Files()
  Dim StrFolder As String, MainDoc As Document, i As Long
  Set MainDoc = ActiveDocument
  StrFolder = MainDoc.Path & "\"
  With MainDoc.MailMerge
    .Destination = wdSendToNewDocument
    .SuppressBlankLines = True
    .ViewMailMergeFieldCodes = False
    With .DataSource
      .ActiveRecord = wdFirstRecord
      Do Until i = .ActiveRecord  'next record didn't go forward
        MainDoc.SaveAs FileName:=StrFolder & i & "temp.pdf", FileFormat:=wdFormatPDF, AddToRecentFiles:=False
        i = .ActiveRecord
        .ActiveRecord = wdNextRecord
      Loop
    End With
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote