Solved

Folder Lookup

Posted on 1999-01-29
6
276 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
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.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 7 35
Launch app from Access custom ribbon 8 33
date criteria to pull up records for the last 3 months 39 42
Help with MS Access search Form 7 18
This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

832 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