将每张幻灯片上的所有形状分组并将图片保存为 SVG 文件

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

在每张幻灯片上,我想选择所有形状,然后将其分组并保存为 SVG 文件,然后转到下一张幻灯片直到最后一张幻灯片。到目前为止,这就是我所拥有的,但它无法正常运行。任何建议将不胜感激。

这是我到目前为止的代码

Sub GroupandsaveSVG()
    Dim folderPath As String
    Dim sld As Slide
    Dim shp As Shape
    
    folderPath = Environ("USERPROFILE") & "\Desktop\mySVGs\"
    On Error Resume Next
    MkDir folderPath
    
    For Each sld In ActivePresentation.Slides
    For Each shp In sld.Shapes.SelectAll
    Selection.Group
    Call .Export(folderPath & "Shape" & CStr(x) & ".svg", ppShapeFormatSVG)
    
Next
Next
End Sub

谢谢你

vba powerpoint
1个回答
0
投票
  • 使用
    Shapes.Range.Group
  • 对形状进行分组
  • 使用
    Shapes.Range.Export
  • 导出为 svg 图像
Option Explicit

Sub GroupSaveSVG()
    Dim folderPath As String
    Dim Sld As Slide
    Dim Shp As Shape
    Dim i As Integer
    folderPath = Environ("USERPROFILE") & "\Desktop\mySVGs\"
    On Error Resume Next
    MkDir folderPath
    On Error GoTo 0
    For Each Sld In ActivePresentation.Slides
        With Sld.Shapes.Range
            If .Count > 1 Then .Group
            .Export folderPath & "Shape" & CStr(i + 1) & ".svg", ppShapeFormatSVG
        End With
        i = i + 1
    Next
End Sub
© www.soinside.com 2019 - 2024. All rights reserved.