4
votes

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

3
As Steve said. The zoom object is a special object that cannot be created using VBA. You could using OpenXml though.Shyam Pillai

3 Answers

5
votes

There doesn't seem to be anything in the object model (at least as seen by VBA) that would help with this. Shapes and ShapeRanges now have a HasSectionZoom property, but this returns false, even for shapes that have been inserted using the Zoom | Section Zoom feature.

Alt NY2C will at least get you to the Insert Section Zoom dialog box quickly.

2
votes

I've just come across a need for this and the HasSectionZoom property is still not returning the expected result nor is there anything new in the OM in PowerPoint 2016 Insider version 1809, build 10813.20004 to aid in the automation of zoom content creation. But in addition to Steve's key stroke method for opening the Insert Section Zoom dialog, you can use these methods to do the same:

Application.CommandBars.ExecuteMso "MSPPTInsertTableofContents"
Application.CommandBars.ExecuteMso "SectionZoomInsert"
Application.CommandBars.ExecuteMso "SlideZoomInsert"

I just love the way the idMSO control names are nice and consistent ;-)

0
votes

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!