Open Folder Dialog - setting initial directory
Posted on 2006-11-28
I've been using the following code (found months ago on EE) to open a "set folder" dialog:
Const BIF_RETURNONLYFSDIRS = &H1
Const BIF_EDITBOX = &H10
Const BIF_DONTGOBELOWDOMAIN = &H2
Const procname As String = "btn_UpdateFolder_Click"
On Error GoTo Err
Dim oShell As Object
Dim sPath As String
Set oShell = CreateObject("Shell.Application")
On Error Resume Next
sPath = oShell.BrowseForFolder(hwnd, "Select folder for AQ database", BIF_RETURNONLYFSDIRS Or BIF_EDITBOX).Items.item.Path
If sPath = "" Then sPath = "Nothing"
'MsgBox "You select " & sPath & " from folder dialog.", vbInformation, "Browse for folders"
txt_Database_Path = sPath
'save to registry
SaveSetting App.Title, "Settings", "mdb_FolderPath", sPath
Set oShell = Nothing
While the above does the job, it become rather tiresome for users who have to navigate several sub-folders to get to the one they need. I've tried various ways of setting the initial directory and am keen to succeed -your help is most appreciated.