Solved

Folder Lookup

Posted on 1999-01-29
6
254 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
6 Comments
 
LVL 5

Expert Comment

by:dtomyn
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 8

Expert Comment

by:Helicopter
Comment Utility
Yes, you just delete it.
0
 
LVL 5

Accepted Solution

by:
dtomyn earned 100 total points
Comment Utility
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
Comment Utility
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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now