Solved

Folder Lookup

Posted on 1999-01-29
6
297 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
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 …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

729 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