我有代码可以将幻灯片导出为 PNG 文件,前提是它们满足特定条件(即幻灯片中具有特定的命名形状)。有时幻灯片没有任何已知的形状名称,但它们将位于命名的“部分”内。
我知道我必须以某种方式使用 ActivePresentation.SectionProperties,但我不确定如何去做。我已经按照下面的代码进行了尝试,但没有成功。在此示例中,该部分的名称是“Test”。将会有许多不同的部分,我需要对其中的几个部分执行此操作。任何帮助将非常感激。谢谢你!
Dim sld As Slide
i = 1
For Each sld in ActivePresentation.Slides
If ActivePresentation.SectionProperties.Name("Test") Then
ActivePresentation.Slides(i).Export filenamepng & "TEST" & i & ".png", "PNG"
End If
i = i + 1
Next
Run Code Online (Sandbox Code Playgroud)
小智 5
@猎人21188
我想这就是你所需要的。
您将检查每张幻灯片属于哪个部分。之后,您验证它是否来自“测试”部分,如果是真的,陷阱!出口。
观察。该函数将SectionIndex从Slide Atribute转换为不在Slides集合中的SectionName。
Sub Test_Export()
Dim sld As Slide
i = 1
DesiredSection = SectionIndexOf("Test")
For Each sld In ActivePresentation.Slides
If sld.sectionIndex = DesiredSection Then
ActivePresentation.Slides(i).Export filenamepng & "TEST" & i & ".png", "PNG"
End If
i = i + 1
Next
End Sub
Function SectionIndexOf(sSectionName As String) As Long
Dim x As Long
With ActivePresentation.SectionProperties
For x = 1 To .Count
If .Name(x) = sSectionName Then
SectionIndexOf = x
End If
Next
End With
End Function
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
717 次 |
最近记录: |