VBA FileDialog 将 powerpoint 保存为 .ppt 而不是 .pptx
VBA FileDialog saves powerpoint as .ppt instead of .pptx
我有一个带有几个宏的 PowerPoint:一个允许您从 Word 加载一些数据,另一个将 PowerPoint 导出到 Word 所在的相同位置。这是后者:
Sub export()
Dim dlgSaveAs As FileDialog
Dim strMyFile As String
Dim ppPres As Presentation
Set dlgSaveAs = Application.FileDialog(Type:=msoFileDialogSaveAs)
With dlgSaveAs
.InitialFileName = path & "Exported without macros - " & company & " (((insert date)))"
If .Show = -1 Then
strMyFile = .SelectedItems(1)
'MsgBox strMyFile
ActivePresentation.SaveAs strMyFile, 1
'-- save your file to strMyFile here
Else
'MsgBox "No file selected."
'-- The user pressed Cancel.
End If
End With
Set dlgSaveAs = Nothing
End Sub
说实话,这段代码不是我写的。我几个月前发现它并对其进行了改编,但我不知道它是如何工作的。
问题是当 'Save As' FileDialog 打开时,文件扩展名似乎没问题:
但是在按下 'save' 之后,文件被保存为 .ppt:
知道如何解决这个问题吗?
改变这个:
ActivePresentation.SaveAs strMyFile, 1
对此:
ActivePresentation.SaveAs strMyFile, 24
或到
ActivePresentation.SaveAs strMyFile, ppSaveAsOpenXMLPresentation
我有一个带有几个宏的 PowerPoint:一个允许您从 Word 加载一些数据,另一个将 PowerPoint 导出到 Word 所在的相同位置。这是后者:
Sub export()
Dim dlgSaveAs As FileDialog
Dim strMyFile As String
Dim ppPres As Presentation
Set dlgSaveAs = Application.FileDialog(Type:=msoFileDialogSaveAs)
With dlgSaveAs
.InitialFileName = path & "Exported without macros - " & company & " (((insert date)))"
If .Show = -1 Then
strMyFile = .SelectedItems(1)
'MsgBox strMyFile
ActivePresentation.SaveAs strMyFile, 1
'-- save your file to strMyFile here
Else
'MsgBox "No file selected."
'-- The user pressed Cancel.
End If
End With
Set dlgSaveAs = Nothing
End Sub
说实话,这段代码不是我写的。我几个月前发现它并对其进行了改编,但我不知道它是如何工作的。
问题是当 'Save As' FileDialog 打开时,文件扩展名似乎没问题:
但是在按下 'save' 之后,文件被保存为 .ppt:
改变这个:
ActivePresentation.SaveAs strMyFile, 1
对此:
ActivePresentation.SaveAs strMyFile, 24
或到
ActivePresentation.SaveAs strMyFile, ppSaveAsOpenXMLPresentation