bjames
asked on
Folder Lookup
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?
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?
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.
ASKER
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?
Yes, you just delete it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
Thanks
Declare Function MSAU_OfficeGetFileName Lib "msaccess.exe" Alias "#56" (gfni As WLIB_OFFICEGETFILENAMEINFO
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
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(of
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