VBA代码将PowerPoint文件转换为Window Media播放器文件

时间:2016-03-27 17:48:26

标签: excel vba excel-vba powerpoint

我想通过Excel VBA代码将PowerPoint文件(pptx)保存为Window Media视频(.wmv)。是否可以通过VBA转换文件?

1 个答案:

答案 0 :(得分:1)

在Excel中,您可以按如下方式创建过程:

Public Sub CreateVideo()
    Dim papp As PowerPoint.Application
    Dim p As PowerPoint.Presentation

    Set papp = CreateObject("Powerpoint.Application")

    Set p = papp.Presentations.Open("mypresentation.pptx")

    p.CreateVideo "myvideo.wmv"
End Sub

重要提示:在VBA编辑器中,您需要选择“选项” - > “参考”;在那里你需要检查“Microsoft Powerpoint 15.0对象库”。否则它将无法工作。