VBA Code to merge exported pdf files

New Contributor

The following code generates individual pdf files, but I need all files merged into a single pdf file. Please help me to edit this code.



Sub tt()
    
    Dim i As Integer
    Dim fname As String

    For i = 2 To 6
        
        Sheet2.Cells(2, "B").Value = Sheet1.Cells(i, 1).Value
        fname = Sheet1.Cells(i, 1).Value & "_" & "Result"
        
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "G:\1\" & fname & ".pdf", _
        Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=False, OpenAfterPublish:=False
    
    Next
    
    
End Sub

 

0 Replies