Select folder dialog box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to call the standard windows Folder Selection dialog box. The
open/save dialog box doesn't seem to offer me this option. Any ideas? I just
want the user to be able to browse folders, then select one, and return the
folder name and path to my code.

Thoughts/suggestions/insults?
 
Hi Robert,

here is a link to the BrowseFolder Dialog written by Terry
Kreft

http://www.mvps.org/access/api/api0002.htm

If the folder that is being chosen will have a file in it, I
like to use the OpenFile dialog and instruct them to pick a
file in the folder that they want since the function to
choose a folder always starts you at the root of the drive.
Then I parse the filename out of what is returned and just
store the path

In the code to open a file, you can specify a start directory

Call the standard Windows File Open/Save dialog box by
Ken Getz

http://www.mvps.org/access/api/api0001.htm



Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
Oh yeah, that's an ugly shirt you're wearing. (you said you wanted insults!)

I can't help it, my mom dresses (and I'm 43).
Douglas J Steele said:

I am currently using that code for my FILE open/save dialog. What I need is
to simply select a folder, not the file. I must be missing something here. I
could build one with fileattrib(), but that would be a pain.
 
Hi Robert,

to parse the filename, you can do this:

'~~~~~~~~~~~~~~
Dim mPath As String, mFile As String
mPath = GetOpenFile("Pick an file in the Directory for
Excel Export Path", "*.*")
If Len(mPath) > 0 Then
mFile = Dir(mPath)
mPath = Left(mPath, Len(mPath) - Len(mFile))
Me.ExportPath = mPath
End If
'~~~~~~~~~~~~~~

to make it easier to call Ken's code, I wrote a general
function -- this goes in a general module

'------------------------------ BrowseFile
Function BrowseFile( _
pTitle As String, _
Optional pFilter As String, _
Optional pInitialDir As String) _
As String

'CALLS -->
'ahtCommonFileOpenSave

On Error GoTo Proc_Err

Dim mFilename As String

mFilename = Nz(ahtCommonFileOpenSave( _
ahtOFN_FILEMUSTEXIST Or _
ahtOFN_HIDEREADONLY Or _
ahtOFN_NOCHANGEDIR, _
IIf(IsMissing(pInitialDir), _
CurrentProject.Path, pInitialDir), _
pFilter, _
, , , pTitle, , True))

If Len(mFilename) = 0 Then Exit Function

On Error Resume Next

BrowseFile = mFilename

Proc_Exit:
Exit Function

Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number & " BrowseFile"
'comment out next line after debugged
Stop: Resume
Resume Proc_Exit

End Function

'~~~~~~~~~~~~~~~~~~~~

you can also use his Function GetOpenFile, which takes
varDirectory and varTitleForDialog as parameters.
Sometimes, I want to send a filter, which is why I made a
seperate BrowseFile function in my databases

'~~~~~~~~~~~~~~~~~~~~

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
Back
Top