Newsgroup: it.comp.appl.access
Titolo: per prelevare solo la directory al posto del file

sapete come poter modificare la funzione qui sotto per prelevare una
cartella anzichč un file
Public Sub ShowFile3(frm As Form, fb As OPENFILENAME)
    Dim fName As String
    Dim result As Long
    Dim path As String
    path = "c:\"
    With fb
        .lStructSize = Len(fb)                      'Size of the structure
        .hwndOwner = frm.hwnd                       'Handle to window
opening the dialog
        .hInstance = 0                              'Handle to calling
instance (not needed)
        .lpstrFilter = "Tutti i File (*.mdb)" & vbNullChar & "*.mdb" &
vbNullChar
                        '& "GIF Files (*.gif)" & vbNullChar & "*.bmp" &
vbNullChar _
                        '& "JPG Files (*.jpg)" & vbNullChar & "*.bmp" &
vbNullChar & vbNullChar
        '.lpstrCustomFilter is ignored -- unused string
        .nMaxCustomFilter = 0
        .nFilterIndex = 1                           'Default filter is the
first one (Text Files, in this case)
        .lpstrFile = Space(256) & vbNullChar        'No default filename.
Also make room for received path and _
                                                     filename of the user's
ion.
        .nMaxFile = Len(.lpstrFile)
        .lpstrFileTitle = Space(256) & vbNullChar   'Make room for filename
of the user's ion
        .nMaxFileTitle = Len(.lpstrFileTitle)
        .lpstrInitialDir = path & vbNullChar        'Initial directory is
C:\
        .lpstrTitle = "Seleziona la Foto" & vbNullChar    'Title of file
dialog
        .Flags = OFN_PATHMUSTEXIST Or OFN_FILEMUSTEXIST Or OFN_HIDEREADONLY
        .nFileOffset = 0                            'The rest of the options
aren't needed.
        .nFileExtension = 0
        '.lpstrDefExt is ignored -- unused string
        .lCustData = 0
        .lpfnHook = 0
        '.lpTemplateName is ignored -- unused string
    End With
    result = GetOpenFileName(fb)
    If result <> 0 Then
        fName = Left(fb.lpstrFile, InStr(fb.lpstrFile, vbNullChar) - 1)
    End If
End Sub
grazie.

Servito:
Option Compare Database
Option Explicit
Private Type BROWSEINFO
    hOwner As Long
    pidlRoot As Long
    pszDisplayName As String
    lpszTitle As String
    ulFlags As Long
    lpfn As Long
    lparam As Long
    iImage As Long
End Type
Private Const BIF_RETURNONLYFSDIRS = &H1&
' Sfoglia cartelle
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias
"SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias
"SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Function BrowseFolder(szDialogTitle As String) As String
  Dim X As Long, bi As BROWSEINFO, dwIList As Long
  Dim szPath As String, wPos As Integer
    With bi
        .hOwner = hWndAccessApp
        .lpszTitle = szDialogTitle
        .ulFlags = BIF_RETURNONLYFSDIRS
    End With
    dwIList = SHBrowseForFolder(bi)
    szPath = Space$(512)
    X = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)
    If X Then
        wPos = InStr(szPath, Chr(0))
        BrowseFolder = Left$(szPath, wPos - 1)
    Else
        BrowseFolder = ""
    End If
End Function
-- 
Jonathan Canova
www.aladinoinformatica.com


grazie.

 >
Ho un problema perň
io la mia funzione postata  la usavo cosi su click del pulsante
    Call ShowFile(Me, fb)
    fName = Left(fb.lpstrFile, InStr(fb.lpstrFile, vbNullChar) - 1)
    If fName <> "" Then
        Forms![aziendali]![percorso]![PathTabelle] = fName
    End If
come uso la tua?
Grrazi.e

 come uso la tua?
fName = BrowseFolder("Titolo")
If fName <> "" Then
     Forms![aziendali]![percorso]![PathTabelle] = fName
End If
Ciao!