Good morning and thanks for however can assist.

I have been running the Macro below for a while now and it works beautifully for combining the presentations. However, it always converts all the slides into the Theme and Design of the main presentation and I would like to keep the formatting from the original slide.

Is there code to keep that original formatting??

Thanks again.

Sub InsertAllSlides() ' Insert all slides from all presentations in the same folder as this one ' INTO this one; do not attempt to insert THIS file into itself, though.

Dim vArray() As String
Dim x As Long

' Change "*.PPT" to "*.PPTX" or whatever if necessary:
EnumerateFiles ActivePresentation.Path & "\", "*.PPTX", vArray

With ActivePresentation
    For x = 1 To UBound(vArray)
        If Len(vArray(x)) > 0 Then
            .Slides.InsertFromFile vArray(x), .Slides.Count
        End If
End With

End Sub

Sub EnumerateFiles(ByVal sDirectory As String, _ ByVal sFileSpec As String, _ ByRef vArray As Variant) ' collect all files matching the file spec into vArray, an array of strings

Dim sTemp As String
ReDim vArray(1 To 1)

sTemp = Dir$(sDirectory & sFileSpec)
Do While Len(sTemp) > 0
    ' NOT the "mother ship" ... current presentation
    If sTemp <> ActivePresentation.Name Then
        ReDim Preserve vArray(1 To UBound(vArray) + 1)
        vArray(UBound(vArray)) = sDirectory & sTemp
    End If
    sTemp = Dir$

End Sub

1 Answer 1


InsertFromFile doesn't offer much control over formatting (none, actually).

Instead, try the method offered at the bottom of this page: https://software-solutions-online.com/copy-slides-one-presentation-another-vba-powerpoint/

In short:

Sub Example2()
Dim objPresentation As Presentation
Dim i As Integer

'open the target presentation
Set objPresentation = Presentations.Open("C:\2.pptx")
For i = 1 To objPresentation.Slides.Count
    Presentations.Item(1).Slides.Item(Presentations.Item(1).Slides.Count).Design = _
Next i
End Sub

To avoid screen flickering and speed things up, you can use this instead of the above to open the presentation windowlessly:

Set objPresentation = Presentations.Open("C:\2.pptx"),,False

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.