Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 365
  • Last Modified:

Access Directory Picker

I need to use a dialog to select, or create and select a folder.  I'm using the GetOfficeFileName routine from the Access Developer's Handbook to get filenames, but I can't seem to get it to select just a path\folder name, without having to select or point to an actual file.  Anyone familiar with this routine and the various flags?
With gfni
            .strDlgTitle = "Specify the path for the subscription export files:"
'            .strOpenTitle = "Save"
            .strInitialDir = "S:\CPE\" & Me.ItemSched.Column(3) & "\"
            .lngFlags = GfniDirectoryOnly
          End With
 
          If OfficeGetFileName(gfni, 0) = ErrSuccess Then                  
            SelectPath = gfni.strFile 
          End If

Open in new window

0
DHompster
Asked:
DHompster
  • 6
  • 4
  • 2
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
0
 
DHompsterAuthor Commented:
Thanks!  I tried this, but it doesn't seem to allow a new folder to be created, does it?  Plus, the dialog window seems so restrictively narrow.  Is there a way to widen it?
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
I don't know right off hand - either question.  I've  only used it to browser to and select a folder.  Seems there would be properties to allow creating a new folder at least.  Google the windows file browser api ... you might find the settings there.

mx
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Jeffrey CoachmanMIS LiasonCommented:
DHompster,

Well as far as the "Create a folder" requirement...
You can "Shell" out to any disk location and it will open in a Window.
Then you can create folders as you normally would in Windows
Something like this:

Dim varApp As Variant
    varApp = Shell("Explorer.exe" & " " & "C:\YourFolder", vbNormalFocus)

JeffCoachman
0
 
DHompsterAuthor Commented:
Thanks, Jeff.  Unfortunately, that wouldn't fulfill the purpose of returning a specific path/folder name to a VBA variable.
0
 
Jeffrey CoachmanMIS LiasonCommented:
Yes but I thought it would help with the "Create a folder" requirement...

(as I stated first in my post)
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
ok ... I just check my folder browse ... and it has everything you need ... and I got this one from Getz's book / CD ... now that I think about it.  Unfortunately, I cannot easily get all the pieces to upload.

mx
0
 
DHompsterAuthor Commented:
Can you just paste the section of the code where the flags (.lng) are set?  I have all the other pieces.

Thx!
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
well, sorry .. false alarm.  Turns out that was for the File browse !  Damn.

The ShellBrowse I have is definitely from Getz:

"' Credits:
' This class module is based on code from Access 2000 Developer's Handbook, Volume I,
' by Getz, Litwin, and Gilbert. (Sybex)
' Function names, etc., have been changed to conform with the ADI naming conventions
' Thanks Ken, Paul and Mike.
'-----------------------------------------------------------"
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Attached is the Getz Shell Browse class with a Test Form.  I'm not seeing a Create Folder function ... but maybe you can find it.

mx
ShellBrowseClass.zip
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
The API definition and flags ... commented out (not sure why) are in the

zsvbaXLibSysWinAPI

module.
0
 
DHompsterAuthor Commented:
Found the solution myself:

  Dim lngFlags As Long
  Dim gfni As OfficeGetFileNameInfo
  With gfni
    .lngFlags = lngFlags Or GfniDirectoryOnly
    .strDlgTitle = "Select the Drive/Folder containing the Audio Sample Volume"
    .strOpenTitle = "Select"
    .strFile = ""
    .strInitialDir = GetAppPath & "Audio Samples\"
  End With
  If OfficeGetFileName(gfni, -1) = ErrSuccess Then
    [Volume Path] = Trim(gfni.strFile) & "\"
  End If

If anyone else needs this, you'll also need the code for OfficeGetFileNameInfo.  Just contact me.

Thanks to all who contributed!
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 6
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now