vba - VBA PowerPoint - 如何选择特定幻灯片或按部分选择并导出到 MP4?
问题描述
例如:导出幻灯片编号 30 到 80(导出为 mp4)。一些宏?或者:只导出一个部分。
我找到了一个按部分导出幻灯片的宏,但它是 png 格式,当我切换到 mp4 时它不起作用。(罗德里戈莫拉斯宏)。
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
用户(Albert Floor)可以使用此宏将选定的幻灯片导出为 PDF
Private Sub CommandButton4_Click()
Dim myInput As String
Dim savePath As String\
'Name of Student
myInput = ActivePresentation.Slides(1).Shapes("TextBox2").OLEFormat.Object.Text\
'Location of saved file
savePath = ActivePresentation.Path & "\" & myInput & " Antwoorden Virtueel Lab" & ".pdf" \\\\
'Select path student took
If ActivePresentation.Slides(9).Shapes("TextBox1").OLEFormat.Object.Text = "PRARDT" Then
'Change view
ActivePresentation.SlideShowWindow.View.Exit
'Prevents error
ActiveWindow.Panes(1).Activate
'Select specific slides
ActivePresentation.Slides.Range(Array(9, 11, 15)).Select
'save selected slides as PDF
ActivePresentation.ExportAsFixedFormat Path:=savePath, FixedFormatType:=ppFixedFormatTypePDF, RangeType:=ppPrintSelection
MsgBox "file saved"
Else
MsgBox "wont work"
End If
End Sub
解决方案
我从未将 powerpoint 演示文稿导出到 mp4,但在我拥有的 powerpoint 2013 版本中,您似乎可以在Save As时创建 mp4 。
另存为荣誉隐藏幻灯片。所以一些简单的代码来隐藏幻灯片然后保存为作品,这里是一些示例代码。在此示例中,我隐藏了第五张幻灯片之后的所有幻灯片。
Public Sub Savetomp4()
Dim mySlides As slides
Set mySlides = ActivePresentation.slides
Dim aSlide As Slide
' Hide some slides
For i = 0 To mySlides.Count - 1
If i > 5 Then
Set aSlide = mySlides.Item(i)
aSlide.SlideShowTransition.Hidden = msoTrue
End If
Next i
' Save as mp4
ActivePresentation.SaveAs "c:\temp\test.mp4", ppSaveAsMP4
Debug.Print "Done!"
End Sub
推荐阅读
- sql - SQL Server - 我如何查询仅当销售额超过一定百分比时才能退货?
- swift - 如何调试链接同一库的多个实例的objc运行时
- r - 使用 R dplyr 根据多个条件找到最佳可能组合
- python - 是否可以在 Python 中使用具有对象字段的复杂对象列表中的切片
- javascript - ReactNative:TypeError:this.props.navigation.navigate 不是函数
- kubernetes - 已安装 prometheus-community / helm-charts 但我无法获取“默认”命名空间的指标
- node.js - 如何设置浏览器“授权”标头?
- http - GoLang:单击“返回”按钮时阻止浏览器缓存页面
- python - 如何获取它以便它 fill_between 获取所有区域,直到 y 达到 0 而不是仅填充有多个 y=1 值的实例
- android - 如何在运行 android Q 及以下的设备中获得与 LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS 相同的功能?