Consulting

Results 1 to 6 of 6

Thread: PPT Master slide VBA help

  1. #1
    VBAX Newbie
    Joined
    Nov 2023
    Posts
    5
    Location

    PPT Master slide VBA help

    Hi, I am trying to create a macro that will re-insert master slides from a template from a location on the network, in case people delete them, I have the code below, it seems to work and run fine, but when you go into the master the slides aren’t added. I am not fully confident in vba so need a little help if possible

    Thanks in advance

    Sub CopyMasterSlidesFromNetwork()    ' Specify the path to the PowerPoint file on the network
        Dim sourceFilePath As String
        sourceFilePath = "\\Network\Path\To\Your\Source\File.pptx" ' Replace with the actual network path
    ' Open the source presentation
        Dim sourcePresentation As Presentation
        Set sourcePresentation = Presentations.Open(sourceFilePath)
    ' Copy master slides from the source presentation
        Dim slideIndex As Integer
        For slideIndex = 1 To sourcePresentation.Slides.Count
            sourcePresentation.Slides(slideIndex).CustomLayout.Copy
            ActivePresentation.Designs(1).SlideMaster.CustomLayouts.Paste
        Next slideIndex
    ' Close the source presentation without saving changes
        sourcePresentation.Close False
    End Sub

  2. #2
    Maybe try using this command instead
    ActivePresentation.Slides.InsertFromFile FileName:="source.pptm", Index:=1, SlideStart:=2, SlideEnd:=4
    Slides.InsertFromFile method (PowerPoint) | Microsoft Learn

  3. #3
    VBAX Newbie
    Joined
    Nov 2023
    Posts
    5
    Location
    Quote Originally Posted by jdelano View Post
    Maybe try using this command instead
    ActivePresentation.Slides.InsertFromFile FileName:="source.pptm", Index:=1, SlideStart:=2, SlideEnd:=4
    Slides.InsertFromFile method (PowerPoint) | Microsoft Learn

    thanks for the code, this looks like it’s just inserting slides rather than the masters, is that right? I am a newbie to vba, apologies if not

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,095
    Location
    To get back to the original problem:

    Are you saying that users are physically deleting custom layouts OR they delete a slide and the corresponding layout also deletes OR something else.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    VBAX Newbie
    Joined
    Nov 2023
    Posts
    5
    Location
    Quote Originally Posted by John Wilson View Post
    To get back to the original problem:

    Are you saying that users are physically deleting custom layouts OR they delete a slide and the corresponding layout also deletes OR something else.

    yes so sometimes users go into the masters and delete them due to file size increasing, however I would like to be able to apply the template to the current file, which then re-inserts the master slides of the template

  6. #6
    VBAX Newbie
    Joined
    Sep 2024
    Posts
    2
    Location
    yes so sometimes users go into the masters and delete them due to file size increasing, however I would like to be able to apply the template to the current file, which then re-inserts the master slides of the template
    What steps can be taken to prevent users from unintentionally deleting custom layouts while still allowing for the application of a template to reinsert master slides in a presentation?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •