Powerpoint VBA Macro Save As Dialog File Filter

2019-07-17 00:58发布

I want to export a PPT presentation to an .html file. Therefore I have the VBA code

Sub HTMLExport()
    ActivePresentation.SaveAs "C\Users\test\pptInHtml.htm", ppSaveAsHTML, msoFalse
End Sub

This works, but I need the code for a "Save As Dialog Box", where the user can choose the path where the file will be saved as html (the user can only pick "save as html", nothing else).

This is the code for my SaveAsDialog

Sub ShowSaveAsDialog()
Dim dlgSaveAs As FileDialog
Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
With dlgSaveAs
  If .Show = -1 Then
    .Execute
  End If
End With
End Sub

But now, I need the file filter for an .html file.

1条回答
冷血范
2楼-- · 2019-07-17 01:42

MS Office SaveAs type FileDialog with a filter in vb states that custom filters unfortunately cannot be used for a Save As dialog.

So it seems like the best option is to create the dialog using Windows API as the answer by the OP suggests.

查看更多
登录 后发表回答