mosaad
mosaad

Reputation: 2371

C# Copy powerpoint Master Slide layout

I want to copy master layout from one presentation to another. If I wanted to copy a slide the code would be Presentation.Slides[1].Copy, however I can't find similar code for copying master layout. There is Presentation.SlideMaster.Delete() but for some reason there is no copy. If it is not possible in c# is it possible in vba??

I want to basically automate this

Upvotes: 2

Views: 805

Answers (1)

Shyam Pillai
Shyam Pillai

Reputation: 586

This is the VBA code to copy a design from one presentation to the other - http://skp.mvps.org/pptxp018.htm. The same is achievable in C#.

Sub CopyDesigns()

    Dim oSourceDesigns As Presentation
    Dim I As Integer
    Set oSourceDesigns = Presentations.Open("K:\Docs\main.pot", , , False)
    
    For I = 1 To oSourceDesigns.Designs.Count
        ActivePresentation.Designs.Clone oSourceDesigns.Designs(I)
    Next I
    
    oSourceDesigns.Close
    Set oSourceDesigns = Nothing

End Sub

Upvotes: 2

Related Questions