将PowerPoint pptm保存到pptx [英] Save PowerPoint pptm to pptx

查看:364
本文介绍了将PowerPoint pptm保存到pptx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在VBA中迈出第一步。
我一直在尝试很多事情,但是仍然没有想出一种方法来将.pptm powerpoint演示文稿保存为.pptx格式,并在特定路径中使用相同的文件名?
我已经使用以下代码另存为pdf。

I am making my first steps in VBA. I have been trying many things, but still I haven't figured out a way to save a .pptm powerpoint presentation to .pptx format with the same file name in a specific path? I already use the following code to save as pdf.

ActivePresentation.ExportAsFixedFormat c:\ + Replace(ActivePresentation。名称, pptm, pdf),ppFixedFormatTypePDF,ppFixedFormatIntentPrint,msoCTrue

谢谢。

推荐答案

基本用法是:

With ActivePresentation
    .SaveCopyAs _
        FileName:=.Path & "\" & Left(.Name, InStrRev(.Name, ".")) & "pptx", _
        FileFormat:=ppSaveAsOpenXMLPresentation
End With

(或您可以使用.SaveAs。SaveAsCopy使当前文件保持打开状态,而不会打开副本,而.SaveAs将当前文件设置为已保存的版本)

(Or you can use .SaveAs. SaveAsCopy keeps the current open and doesn't open the copy, whereas .SaveAs sets the current to be the saved version)

但是,如果您要保存的Powerpoint至少没有保存过一次,否则以上操作将出错(Presentation.Name中没有文件扩展名,可通过InStrRev查找)。您可以测试是否有句号,也可以使用一种懒惰的方法来询问FileSystemObject以不带扩展名的名称来命名(我很懒,所以我更喜欢这种方法):

However, if the Powerpoint you are saving hasn't been saved at least once then the above will error (there is no file extension in Presentation.Name to find with InStrRev). You can either test for there being no full stop, or you can use a lazy method of asking FileSystemObject to get you the name without an extension (I am lazy so I prefer this method):

因此,一种更好的更健壮的方法是:

So a better more robust method is:

Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")

With ActivePresentation
    .SaveCopyAs _
        FileName:=fso.BuildPath(.Path, fso.GetBaseName(.Name) & ".pptx"), _
        FileFormat:=ppSaveAsOpenXMLPresentation
End With

这篇关于将PowerPoint pptm保存到pptx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆