使用 VBA 将演示文稿中使用的主幻灯片提取为 PNG?

问题描述 投票:0回答:1

我想将演示文稿中使用的主幻灯片提取为 PNG。 但是,我正在努力引用幻灯片以便将其提取出来。

我现在拥有的最好的是

...
' Extract background images
For Each Slide In ActivePresentation.Slides
  ' what is the reference for the master layout
  MsgBox "slide layout =  " & Slide.Layout
    
  End If
Next
...

我可以看到here我可以引用布局母版幻灯片,但我找不到如何导出它。 Phind 认为我可以使用母版创建一张空白幻灯片,然后以这种方式导出,但它似乎不喜欢这样。

作为额外的挑战 - 我意识到我正在运行 Powerpoint 2010! :)

vba powerpoint
1个回答
0
投票

这个怎么样:

Sub ExportMasterSlidesToPNG()
    Dim sld As Slide
    Dim masterSlide As master
    Dim i As Integer

    i = 1 ' Counter for exported PNG files
    
    ' Loop through all slides in the presentation
    For Each sld In ActivePresentation.Slides
        ' Check if the slide is a master slide
        If sld.Master Is Nothing Then
            ' Slide is not a master slide; do nothing
        Else
            ' Slide is a master slide; export it as a PNG
            Set masterSlide = sld.Master
            masterSlide.Copy
            With New Presentation
                .Slides.Paste
                .SaveAs "C:\Path\To\Export\Location\MasterSlide_" & i & ".png", ppSaveAsPNG
                .Close
            End With
            i = i + 1
        End If
    Next sld
End Sub
© www.soinside.com 2019 - 2024. All rights reserved.