سؤال

I want to create a 'save as' file dialog with a filter, but this doesn't seem possible using the FileDialog class (Microsoft Office 12.0 Object Library). The documentation actually mentions this here, see last paragraph, but gives no reason as to why? Is there another way of achieving this in vb?

I find it strange that the FileDialog class doesn't allow this because Word, Excel and Access all have this exact SaveAs feature built-in.

I realise that the FileDialog can created as a FilePicker (msoFileDialogFilePicker) which does allow filters, but then this doesn't allow a file to be selected that doesn't yet exist, which defeats the whole point.

هل كانت مفيدة؟

المحلول 2

As @AlexK mentioned the only way to do this is using a windows API call. See here

نصائح أخرى

That appears to be a restriction of that particular class for some reason, so how 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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top