0
Sub insert_zoom()
    Dim pTargetSlide As slide, pNewSlide As slide _
        , pLayout As CustomLayout _
        , pShape As shape _
        , i As Integer

    With Application.ActivePresentation
        Set pLayout = .Slides(1).CustomLayout
        Set pTargetSlide = Application.ActiveWindow.View.slide
        Set pNewSlide = .Slides.AddSlide(.Slides.Count + 1, pLayout)
    End With

    With pNewSlide
        .Select
        .Shapes.Paste
        .SlideShowTransition.Hidden = msoTrue
    End With

    pTargetSlide.Select
    Application.CommandBars.ExecuteMso "SlideZoomInsert"
    
    For i = 1 To pNewSlide.SlideNumber - 1
        SendKeys ("{RIGHT}")
    Next i
    SendKeys (" ~")

 
 End Sub

Getting error in code line : Application.CommandBars.ExecuteMso "SlideZoomInsert"

error ref:

error in code:

I have already added all sections to the slide, just need a code to insert summary slide.

Added Sections in slides

need a VBA code to insert Summary slide: in the below manner:

final output image slide

I have tried this code:

Sub insert_zoom()
    Dim pTargetSlide As slide, pNewSlide As slide _
        , pLayout As CustomLayout _
        , pShape As shape _
        , i As Integer

    With Application.ActivePresentation
        Set pLayout = .Slides(1).CustomLayout
        Set pTargetSlide = Application.ActiveWindow.View.slide
        Set pNewSlide = .Slides.AddSlide(.Slides.Count + 1, pLayout)
    End With

    With pNewSlide
        .Select
        .Shapes.Paste
        .SlideShowTransition.Hidden = msoTrue
    End With

    pTargetSlide.Select
    Application.CommandBars.ExecuteMso "SlideZoomInsert"
    Application.CommandBars.GetEnabledMso True
    Application.CommandBars.ExecuteMso 1

    For i = 1 To pNewSlide.SlideNumber - 1
        SendKeys ("{RIGHT}")
    Next i
    SendKeys (" ~")

 
 End Sub

I am trying to insert summary slide based on sections.

braX
  • 11,506
  • 5
  • 20
  • 33
sip007
  • 1
  • 1
    The first procedure you posted worked on my computer: the zoom was created without issues, The second had the same error you mention were you placed the first of the attempted fixes `Application.CommandBars.GetEnabledMso True` and `Application.CommandBars.ExecuteMso 1` . Found here in the comments below: https://stackoverflow.com/q/57269151/18247317 **"People here have found out that "ExecuteMso doesn't complete until the sub has finished. Therefore the last part of the sub can't execute correctly." The solution was to outsource that command to another Sub."** – Oran G. Utan Jul 29 '23 at 11:52
  • 1
    PowerPoint 2016 doesn't have the Slide Zoom feature, so ExecuteMso can't run it. You should be able to run that code in PowerPoint 2019 and 2021. It works as expected in the 365 version of PowerPoint. – John Korchok Jul 30 '23 at 19:34

0 Answers0