仅导出 Powerpoint 中特定部分内的幻灯片 VBA
Export Only Slides Within a Certain Section in Powerpoint VBA
我有代码可以将满足特定条件的幻灯片导出为 PNG 文件(即在幻灯片中具有特定的命名形状)。有时幻灯片没有任何已知的形状名称,但它们将在命名的 "section" 中。
我知道我必须以某种方式使用 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
@Hunter21188
我猜这就是你需要的。
您将检查每张幻灯片属于哪个部分。
在此之后,您验证它是否来自 "Test" 部分,如果是真的就明白了!导出。
观察。该函数将 SectionIndex 从 Slide 属性转换为不在 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
我有代码可以将满足特定条件的幻灯片导出为 PNG 文件(即在幻灯片中具有特定的命名形状)。有时幻灯片没有任何已知的形状名称,但它们将在命名的 "section" 中。
我知道我必须以某种方式使用 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
@Hunter21188
我猜这就是你需要的。
您将检查每张幻灯片属于哪个部分。 在此之后,您验证它是否来自 "Test" 部分,如果是真的就明白了!导出。
观察。该函数将 SectionIndex 从 Slide 属性转换为不在 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