Search code examples
vbapowerpoint

Inserting a Slide Zoom in PowerPoint 2016 using vba


PowerPoint 2016 has a neat new feature where you can insert Zoom Slides/Sections. See here if you don't know what I'm talking about: https://support.office.com/en-us/article/Use-Zoom-for-PowerPoint-to-bring-your-presentation-to-life-9d6c58cd-2125-4d29-86b1-0097c7dc47d7

I'm trying to automate this process since I use this feature 20-30 times per presentation. For visibility, the workflow I want to automate is the following:

  1. Take screenshot of application/screen
  2. Insert new, blank slide in PowerPoint
  3. Paste screenshot in slide and adjust size/position
  4. Hide the new slide
  5. Insert the screenshot-slide as a Slide Zoom in another slide

I've got steps 1-4 in a VBA macro already, but I can't figure out if there's a vba command to insert a Slide Zoom. My fear is that since this feature is new to 2016 then it's not in VBA yet.

Anyone knows a VBA command line to automate step 5 above?

Thanks in advance!

Vincent


Solution

  • Thanks to Steve Rindsberg and Jamie Garroch for their answers.

    With a little more work I was able to combine the two and get to the result I was originally looking for. I figured I should be able to do it using only the SendKeys command, but somehow I couldn't figure out how to input the Alt keys. Anyhow, the SendKeys would give me trouble when testing and debugging since it would actually type the keys in the module if the focus was there rather than on the presentation.

    Here's my final solution:

    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
    

    More code might be needed to capture and format whatever you paste into the new slide. For now I'm working with large resolution images which default to their maximum size when pasted, so there was no need any formatting or manipulation on my end.

    Cheers!