Solved

Folder Lookup

Posted on 1999-01-29
6
284 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
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 8

Expert Comment

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

Accepted Solution

by:
dtomyn earned 100 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access Query on CSV returning number not text 6 37
database opened as read only 10 32
UK Date format in MS Access 4 23
Use after update to change dates 2 16
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions 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 Microsoft Ac…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

828 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