MS Office SaveAs type FileDialog with filter in vb

I want to create a Save As dialog with a filter, but this is not possible using the FileDialog class (Microsoft Office 12.0 Object Library). The documentation actually mentions this one here , see the last paragraph, but gives no reason why? Is there any other way to achieve this in vb?

It is strange to me that the FileDialog class does not allow this, because Word, Excel and Access have a built-in SaveAs built-in function.

I understand that FileDialog can be created as a FilePicker (msoFileDialogFilePicker) that allows filters, but then it does not allow you to select a file that does not exist yet, which defeats the whole point.

+5
source share
2 answers

As @AlexK mentioned, the only way to do this is to use a Windows API call. See here

0
source

For some reason, this seems limited for this class, so what about:

Dim vResult As Variant
vResult = Application.GetSaveAsFilename("default.blah", "blah files,*.blah,Text file,*.txt,All files,*.*", 0, "Title")
If VarType(vResult) = vbBoolean Then
    MsgBox "cancelled"
Else
    MsgBox vResult
End If
0
source

All Articles