Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Posts
    8

    Unanswered: Getting the Directory Path

    Hi.

    Anyone knows how to get the directory path? I need this to store the directory path for file imports/exports in my system settings table.

    I am able to use CommonDialog in Access 2000 to get the file path, but can't seem to use it to get the directory path. There doesn't seem to be a directory property or something that can help.

    Anyone?

    Thanx and much appreciated.
    Last edited by etes; 05-18-04 at 03:42.

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Cool

    Copy and past the next code in a Module
    PHP Code:
    Type tagOPENFILENAME
        lStructSize 
    As Long
        hwndOwner 
    As Long
        hInstance 
    As Long
        strFilter 
    As String
        strCustomFilter 
    As String
        nMaxCustFilter 
    As Long
        nFilterIndex 
    As Long
        strFile 
    As String
        nMaxFile 
    As Long
        strFileTitle 
    As String
        nMaxFileTitle 
    As Long
        strInitialDir 
    As String
        strTitle 
    As String
        Flags 
    As Long
        nFileOffset 
    As Integer
        nFileExtension 
    As Integer
        strDefExt 
    As String
        lCustData 
    As Long
        lpfnHook 
    As Long
        lpTemplateName 
    As String
    End Type

    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 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
                
    Private Const BIF_RETURNONLYFSDIRS = &H1

    Declare Function aht_apiGetOpenFileName Lib "comdlg32.dll" _
        Alias 
    "GetOpenFileNameA" (OFN As tagOPENFILENAME) As Boolean
    Declare Function aht_apiGetSaveFileName Lib "comdlg32.dll" _
        Alias 
    "GetSaveFileNameA" (OFN As tagOPENFILENAME) As Boolean
    Declare Function CommDlgExtendedError Lib "comdlg32.dll" () As Long
    Global Const ahtOFN_READONLY = &H1
    Global Const ahtOFN_OVERWRITEPROMPT = &H2
    Global Const ahtOFN_HIDEREADONLY = &H4
    Global Const ahtOFN_NOCHANGEDIR = &H8
    Global Const ahtOFN_SHOWHELP = &H10
    ' You won'use these.
    'Global Const ahtOFN_ENABLEHOOK = &H20
    '
    Global Const ahtOFN_ENABLETEMPLATE = &H40
    'Global Const ahtOFN_ENABLETEMPLATEHANDLE = &H80
    Global Const ahtOFN_NOVALIDATE = &H100
    Global Const ahtOFN_ALLOWMULTISELECT = &H200
    Global Const ahtOFN_EXTENSIONDIFFERENT = &H400
    Global Const ahtOFN_PATHMUSTEXIST = &H800
    Global Const ahtOFN_FILEMUSTEXIST = &H1000
    Global Const ahtOFN_CREATEPROMPT = &H2000
    Global Const ahtOFN_SHAREAWARE = &H4000
    Global Const ahtOFN_NOREADONLYRETURN = &H8000
    Global Const ahtOFN_NOTESTFILECREATE = &H10000
    Global Const ahtOFN_NONETWORKBUTTON = &H20000
    Global Const ahtOFN_NOLONGNAMES = &H40000
    New for Windows 95
    Global Const ahtOFN_EXPLORER = &H80000
    Global Const ahtOFN_NODEREFERENCELINKS = &H100000
    Global Const ahtOFN_LONGNAMES = &H200000


    Declare Sub wlib_SplitPath Lib "msaccess.exe" Alias "#59" (ByVal lpszPath As StringByVal lpszDrive As StringByVal lpszDir As StringByVal lpszFname As StringByVal lpszExt As String)



    Public Function 
    BrowseFolder(szDialogTitle As String) As String
      Dim X 
    As Longbi As BROWSEINFOdwIList As Long
      Dim szPath 
    As StringwPos As Integer
      
        With bi
            
    .hOwner hWndAccessApp
            
    .lpszTitle szDialogTitle
            
    .ulFlags BIF_RETURNONLYFSDIRS
        End With
        
        dwIList 
    SHBrowseForFolder(bi)
        
    szPath Space$(512)
        
    SHGetPathFromIDList(ByVal dwIListByVal szPath)
        
        If 
    X Then
            wPos 
    InStr(szPathChr(0))
            
    BrowseFolder Left$(szPathwPos 1)
        Else
            
    BrowseFolder ""
        
    End If
    End Function 
    On your form make a button and write the following in its OnClick event

    PHP Code:
       Dim currFolder
         currFolder
    =BrowseFolder("Any Suitable Message"

  3. #3
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    421
    If all you want is the (sub) folder import from the current database location you can use my code...
    Code:
    Public Function myCurrDir() As String
        myCurrDir = CurrentDb.Name
        Do While Right(myCurrDir, 1) <> "\"
            myCurrDir = Left(myCurrDir, Len(myCurrDir) - 1)
        Loop
    End Function
    This will return the current folder of the current database
    ?myCurrDir
    C:\Temp\

    ?myCurrDir & "Import\"
    C:\Temp\Import

    You can then use that to use Dir to find the file...

    Regards

  4. #4
    Join Date
    May 2004
    Posts
    8
    thanx hammbakka, that worked totally. fantastic!

    btw, any websites that give you more info on calling the windows functions like what you had just given me?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •