Powerpoint Merge Multiple slides

Hello All,

I m having multiple PPT having slides in it. i would like to merge all the files into one ppt.

i want the ppt to be merged as per sequence of file in folder

Can you please help?

Thanks!

Hi @Tejas_Kotharkar

You can use the below code in Invoke Code activity:

' Get all PowerPoint files in the folder in sequence
Dim pptFiles As String() = Directory.GetFiles(folderPath, "*.pptx").OrderBy(Function(x) x).ToArray()

' Initialize PowerPoint application
Dim pptApp As New Application
Dim mergedPresentation As Presentation = pptApp.Presentations.Add(MsoTriState.msoFalse)

Try
    ' Loop through each PowerPoint file and add its slides to the merged presentation
    For Each pptFile As String In pptFiles
        Dim tempPresentation As Presentation = pptApp.Presentations.Open(pptFile, MsoTriState.msoFalse, MsoTriState.msoCTrue, MsoTriState.msoFalse)
        
        For Each slide As Slide In tempPresentation.Slides
            slide.Copy()
            mergedPresentation.Slides.Paste()
        Next

        tempPresentation.Close()
    Next

    ' Save the merged presentation
    Dim outputPath As String = Path.Combine(folderPath, outputFilePath)
    mergedPresentation.SaveAs(outputPath)

Finally
    ' Clean up
    mergedPresentation.Close()
    pptApp.Quit()
    System.Runtime.InteropServices.Marshal.ReleaseComObject(pptApp)
End Try

Invoked Code Arguments:

In the folderPath argument, pass the folder path where your split PPTX files are present.
In the outputFilePath arguments, pass the output file name with which you want the PPTX file to be stored.

If you face any errors please import the three from Imports Panel. Make sure you have UiPath.Presentation.Activities dependency installed.

Microsoft.Office.Interop.PowerPoint
Microsoft.Office.Core
System.IO

Let me know if you get any issues.

Regards

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.