[AccessD] Selecting a directory

MartyConnelly martyconnelly at shaw.ca
Thu Feb 10 12:14:03 CST 2005


Or this method
'This code is a new feature in Access 2002.

Sub testdialog()

'It allows you to browse for a file and then store the selected file in
'2 Text boxes: Me![txtLocalDir] ,  Me![txtLocalFileName]

'1 = DialogOpen, 2= SaveAs, 3=FilePicker, 4 = FolderPicker
'Cannot be used in Access 2000!
  With Application.FileDialog(3)
    .AllowMultiSelect = False
   
    If .Show = True Then
    '  Me![lblEdit].Visible = True
    '  Me![txtLocalDir] = Left$(.SelectedItems(1), 
InStrRev(.SelectedItems(1), "\"))
    '  Me![txtLocalFileName] = Right$(.SelectedItems(1), 
Len(.SelectedItems(1)) - InStrRev(.SelectedItems(1), "\"))
    '  Me![txtLocalFileName].SetFocus
    Debug.Print Left$(.SelectedItems(1), InStrRev(.SelectedItems(1), "\"))
     Debug.Print .SelectedItems(1)
    End If
  End With
End Sub

MartyConnelly wrote:

> Here is one I use but if you want to go up a directory you can't, one 
> reason being to stop users going to places like network neighbourhood
> Needs IE installed. You can also use this to grab filnames from a 
> directory.
>
> 'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/objects/shell/browseforfolder.asp 
>
> 'SHDOC401.DLL for IE5
> '?fnShellBrowseForFolder("c:\access files")
> Function fnShellBrowseForFolder(strRootPath)
>        Dim objShell
>        Dim objFolder
>
>        Set objShell = CreateObject("Shell.Application")
>            Set objFolder = objShell.BrowseForFolder(0, "Example Select 
> Folder", 0, strRootPath)
>                If (Not objFolder Is Nothing) Then
>                    'Add code here.
>                    Debug.Print objFolder.Title
>                    Debug.Print 
> objFolder.ParentFolder.ParseName(objFolder.Title).Path
>                End If
>            Set objFolder = Nothing
>        Set objShell = Nothing
>    End Function
> or
>
> 'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/objects/shell/browseforfolder.asp 
>
> 'SHDOC401.DLL for IE5
> Function fnShellBrowseForFolderWindows()
>        Dim objShell
>        Dim ssfWINDOWS
>        Dim objFolder
>              ssfWINDOWS = 36
>        Set objShell = CreateObject("Shell.Application")
>            Set objFolder = objShell.BrowseForFolder(0, "Example Select 
> Folder", 0, ssfWINDOWS)
>                If (Not objFolder Is Nothing) Then
>                    'Add code here.
>                    Debug.Print objFolder.Title
>                    Debug.Print 
> objFolder.ParentFolder.ParseName(objFolder.Title).Path
>                End If
>            Set objFolder = Nothing
>        Set objShell = Nothing
>    End Function
>
> Gustav Brock wrote:
>
>> Hi John
>>
>> This link might interest you:
>>
>> http://www.lebans.com/callbackbrowser.htm
>> note the link there to vbnet.
>>
>> Also, a German guy, Karsten Pries, has a class module for this which we
>> use here after a major brush up, but it might be what you are looking
>> for:
>>
>> http://www.karstenpries.de/
>>
>> Look for FileDialog. Most of it is in German, but I'm sure you can
>> figure it out.
>>
>> /gustav
>>
>>  
>>
>>>>> jwcolby at colbyconsulting.com 09-02-2005 04:36:59 >>>
>>>>>       
>>>>
>> I have used the ADH FindFile module and function for ages.  However I
>> also
>> need to select a directory (to copy a file to for example) and the ADH
>> code
>> only allows selecting a file, not a dir.  Is there any way to cause
>> that
>> code to select a directory?  Is there another module / function to use
>> the
>> fileFind dialog to select a directory?
>>
>> John W. Colby
>> www.ColbyConsulting.com
>>  
>>
>

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the AccessD mailing list