?
Solved

Folder Lookup

Posted on 1999-01-29
6
Medium Priority
?
302 Views
Last Modified: 2008-02-01
Is there a way to use the common dialog to select a folder?

I'm doing an export of data and want the user to select their destination. I already know the file name.

I'm currently using the common dialog control, but that requires me to select a file in the folder. I would just as soon ignore the files and only show the folders. Can the common dialog do this? Or is there an api call I can make?
0
Comment
Question by:bjames
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Expert Comment

by:dtomyn
ID: 1978083
This is an excerpt from a previous question in which Perove answered (it uses API) I am not posting it as an answer since I think if the Common Dialog can do this instead you would be better off -- the reason why this was posted was because the person (including me later) did not want to use an ActiveX control:

Declare Function MSAU_OfficeGetFileName Lib "msaccess.exe" Alias "#56" (gfni As WLIB_OFFICEGETFILENAMEINFO, ByVal fOpen As Integer) As Long


Option Compare Database
Option Explicit

Type WLIB_OFFICEGETFILENAMEINFO
    hwndOwner As Long
    szAppName As String * 255
    szDlgTitle As String * 255
    szOpenTitle As String * 255
    szFile As String * 4096
    szInitialDir As String * 255
    szFilter As String * 255
    nFilterIndex As Long
    lView As Long
    flags As Long
End Type

Declare Function MSAU_OfficeGetFileName Lib "msaccess.exe" Alias "#56" (gfni As WLIB_OFFICEGETFILENAMEINFO, ByVal fOpen As Integer) As Long


Function SelectDir() As String

On Error GoTo Err_SelectDir
     
    Dim stDir As String
    Dim ofn As WLIB_OFFICEGETFILENAMEINFO
     
    ofn.hwndOwner = hWndAccessApp
    ofn.szAppName = "AppName" & Chr$(0)
    ofn.szDlgTitle = "Search Directory" & Chr$(0)
    ofn.szOpenTitle = "Select" & Chr$(0)
    ofn.szFile = "output.xls" & Chr$(0)
    ofn.szInitialDir = "D:\" & Chr$(0)
    ofn.szFilter = Chr$(0)
    ofn.nFilterIndex = 0
    ofn.lView = 0
    ofn.flags = &H20
     
    If (MSAU_OfficeGetFileName(ofn, True) = 0) Then
        stDir = RightTrim(ofn.szFile)
        SelectDir = stDir
    End If
     
Exit_SelectDir:
    Exit Function
     
Err_SelectDir:
    MsgBox "Error in stp_SelectDir (" & Err.Number & "): " & Err.Description
    Resume Exit_SelectDir
     
End Function

Public Function RightTrim(strToTrim As String) As String

    On Error GoTo Err_RightTrim
     
    Dim posOfNull As Integer
     
    posOfNull = InStr(1, strToTrim, Chr$(0))
    RightTrim = Left$(strToTrim, posOfNull - 1)
     
Exit_RightTrim:
    Exit Function
     
Err_RightTrim:
    MsgBox "Error in RightTrim (" & Err.Number & "): " & Err.Description
    Resume Exit_RightTrim

End Function
0
 
LVL 9

Expert Comment

by:TTom
ID: 1978084
This should be possible.  I once created an application in Word (using Word Basic) which included a file selection dialog box.  If this is what you are trying to do, and using VBA, I may be able to help.  Any code samples you are working with would be useful for starters.
0
 

Author Comment

by:bjames
ID: 1978085
It does address my need, however. And that is all that concerns me in the short term. But since I am now answered, how do I close this question out? Do I just delete it?
0
10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

 
LVL 8

Expert Comment

by:Helicopter
ID: 1978086
Yes, you just delete it.
0
 
LVL 5

Accepted Solution

by:
dtomyn earned 400 total points
ID: 1978087
Well, that depends -- if you used the answer I would suggest that you let me answer it and then you accept the answer.
0
 

Author Comment

by:bjames
ID: 1978088
Yes, I did use the answer, which is why I wanted to 'get permission' to delete it. Your original response did not allow me to credit you with your help and I wanted to give you opportunity to receive that credit.

Thanks
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question