The following class allows you to specify the starting folder and filter(s). For multiple choice folders I would suggest a local DB (.mdb?) to save your favorites.<br>
<br>
<br>
Option Explicit<br>
<br>
Private Type OPENFILENAME<br>
StructSize As Long<br>
hwndOwner As Long<br>
hInstance As Long<br>
Filter As String<br>
CustomFilter As String<br>
MaxCustFilter As Long<br>
FilterIndex As Long<br>
FileFilterIndex As String<br>
MaxFile As Long<br>
FileTitle As String<br>
MaxFileTitle As Long<br>
InitialDir As String<br>
Title As String<br>
flags As Long<br>
FileOffset As Integer<br>
FileExtension As Integer<br>
DefExt As String<br>
CustData As Long<br>
Hook As Long<br>
TemplateName As String<br>
End Type<br>
<br>
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename _<br>
As OPENFILENAME) As Long<br>
<br>
Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename _<br>
As OPENFILENAME) As Long<br>
<br>
Private DefaultExt_ As String<br>
Private DialogTitle_ As String<br>
Private FileName_ As String<br>
Private FileTitle_ As String<br>
Private InitialDir_ As String<br>
Private Filter_ As String<br>
Private FilterIndex_ As Integer<br>
Private Flags_ As FileFlags<br>
Private MaxFileSize_ As Integer<br>
Private hWndParent_ As Long<br>
<br>
Private Const MaxFileLength As Integer = 260<br>
<br>
Public Enum FileFlags<br>
FileReadOnly = &H1<br>
FileOverWritePrompt = &H2<br>
FileHideReadOnly = &H4<br>
FileNoChangeDir = &H8<br>
FileShowHelp = &H10<br>
FileEnableHook = &H20<br>
FileEnableTemplate = &H40<br>
FileEnableTemplateHandle = &H80<br>
FileNoValidate = &H100<br>
FileAllowMultiSelect = &H200<br>
FileExtensionDifferent = &H400<br>
FilePathMustExist = &H800<br>
FileFileMustExist = &H1000<br>
FileCreatePrompt = &H2000<br>
FileShareAware = &H4000<br>
FileNoReadOnlyReturn = &H8000<br>
FileNoTestFileCreate = &H10000<br>
FileNoNetworkButton = &H20000<br>
FileExplorer = &H80000<br>
FileLongnames = &H200000<br>
End Enum<br>
<br>
<br>
Public Property Get DefaultExt() As String<br>
DefaultExt = DefaultExt_<br>
End Property<br>
<br>
Public Property Let DefaultExt(ByVal strValue As String)<br>
DefaultExt_ = strValue<br>
End Property<br>
<br>
Public Property Get DialogTitle() As String<br>
DialogTitle = DialogTitle_<br>
End Property<br>
<br>
Public Property Let DialogTitle(ByVal strValue As String)<br>
DialogTitle_ = strValue<br>
End Property<br>
<br>
Public Property Get FileName() As String<br>
FileName = FileName_<br>
End Property<br>
<br>
Public Property Let FileName(ByVal strValue As String)<br>
FileName_ = strValue<br>
End Property<br>
<br>
Public Property Get FileTitle() As String<br>
FileTitle = FileTitle_<br>
End Property<br>
<br>
Public Property Let FileTitle(ByVal strValue As String)<br>
FileTitle_ = strValue<br>
End Property<br>
<br>
Public Property Get Filter() As String<br>
Filter = Filter_<br>
End Property<br>
<br>
Public Property Let Filter(ByVal FilterValue As String)<br>
Filter_ = FilterValue<br>
End Property<br>
<br>
Public Property Get FilterIndex() As Integer<br>
FilterIndex = FilterIndex_<br>
End Property<br>
<br>
Public Property Let FilterIndex(ByVal intValue As Integer)<br>
FilterIndex_ = intValue<br>
End Property<br>
<br>
Public Property Get flags() As FileFlags<br>
flags = Flags_<br>
End Property<br>
<br>
Public Property Let flags(ByVal eValue As FileFlags)<br>
Flags_ = eValue<br>
End Property<br>
<br>
Public Property Get hWndParent() As Long<br>
hWndParent = hWndParent_<br>
End Property<br>
<br>
Public Property Let hWndParent(ByVal lngValue As Long)<br>
hWndParent_ = lngValue<br>
End Property<br>
<br>
Public Property Get InitialDir() As String<br>
InitialDir = InitialDir_<br>
End Property<br>
<br>
Public Property Let InitialDir(ByVal strValue As String)<br>
InitialDir_ = strValue<br>
End Property<br>
<br>
Public Property Get MaxFileSize() As Integer<br>
MaxFileSize = MaxFileSize_<br>
End Property<br>
Public Property Let MaxFileSize(ByVal intValue As Integer)<br>
MaxFileSize_ = intValue<br>
End Property<br>
<br>
Public Function Show(fOpen As Boolean) As Boolean<br>
Dim of As OPENFILENAME<br>
Dim strChar As String * 1<br>
Dim intCounter As Integer<br>
Dim strTemp As String<br>
<br>
On Error GoTo PROC_ERR<br>
<br>
' Initialize the OPENFILENAME type<br>
of.Title = DialogTitle_ & ""<br>
of.flags = Flags_<br>
of.DefExt = DefaultExt_ & ""<br>
of.StructSize = LenB(of)<br>
of.Filter = Filter_ & "¦¦"<br>
of.FilterIndex = FilterIndex_<br>
<br>
' To make Windows-style filter, replace pipes with nulls<br>
For intCounter = 1 To Len(Filter_)<br>
strChar = Mid$(Filter_, intCounter, 1)<br>
If strChar = "¦" Then<br>
strTemp = strTemp & vbNullChar<br>
Else<br>
strTemp = strTemp & strChar<br>
End If<br>
Next<br>
<br>
' Put double null at end<br>
strTemp = strTemp & vbNullChar & vbNullChar<br>
of.Filter = strTemp<br>
<br>
' Pad file and file title buffers to maximum path length<br>
strTemp = FileName_ & String$(MaxFileLength - Len(FileName_), 0)<br>
of.FileFilterIndex = strTemp<br>
of.MaxFile = MaxFileLength<br>
<br>
strTemp = FileTitle_ & String$(MaxFileLength - Len(FileTitle_), 0)<br>
of.FileTitle = strTemp<br>
of.InitialDir = InitialDir_<br>
of.MaxFileTitle = MaxFileLength<br>
of.hwndOwner = hWndParent_<br>
<br>
' If fOpen is true, show the Open file dialog, otherwise show the Save dialog<br>
If fOpen Then<br>
If GetOpenFileName(of) Then<br>
Show = True<br>
' Assign property variables to appropriate values<br>
FileName_ = TrimNulls(of.FileFilterIndex)<br>
FileTitle_ = TrimNulls(of.FileTitle)<br>
Else<br>
Show = False<br>
End If<br>
Else<br>
If GetSaveFileName(of) Then<br>
Show = True<br>
' Assign property variables to appropriate values<br>
FileName_ = TrimNulls(of.FileFilterIndex)<br>
FileTitle_ = TrimNulls(of.FileTitle)<br>
Else<br>
Show = False<br>
End If<br>
End If<br>
<br>
PROC_EXIT:<br>
<br>
<br>
Exit Function<br>
<br>
PROC_ERR:<br>
<br>
<br>
MsgBox "Error: " & Err.Number & ". " & Err.Description, , "Show"<br>
Resume PROC_EXIT<br>
<br>
End Function<br>
<br>
Private Function TrimNulls(ByVal strIn As String) As String<br>
Dim intPos As Integer<br>
On Error GoTo PROC_ERR<br>
intPos = InStr(strIn, vbNullChar)<br>
If intPos = 0 Then<br>
TrimNulls = strIn<br>
Else<br>
If intPos = 1 Then<br>
TrimNulls = ""<br>
Else<br>
TrimNulls = Left$(strIn, intPos - 1)<br>
End If<br>
End If<br>
<br>
PROC_EXIT:<br>
<br>
<br>
Exit Function<br>
<br>
PROC_ERR:<br>
<br>
<br>
MsgBox "Error: " & Err.Number & ". " & Err.Description, , "TrimNulls"<br>
Resume PROC_EXIT<br>
<br>
End Function<br>