Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Posts
    47

    Unanswered: Get the path of filename.

    Hi,

    Could someone help me to get the path of my mdb filename in VB?

    I need to use it in the ADO connection string.

    Currently I am using it as a function and hard coding the complete path...

    Tried to read through VB Help... tried this as a module in VBA, but didn't work...

    Code:
    Sub ShowFileAccessInfo(filespec)
        Dim fs, d, f, s
        Set fs = CreateObject("Scripting.FileSystemObject")
        Set f = fs.GetFile(filespec)
        s = UCase(f.Path) & vbCrLf
        s = s & "Created: " & f.DateCreated & vbCrLf
        s = s & "Last Accessed: " & f.DateLastAccessed & vbCrLf
        s = s & "Last Modified: " & f.DateLastModified  
        MsgBox s, 0, "File Access Info"
    End Sub
    Rgds

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    The filespec is not defiend, if you replace it with the file name it would function..

    Set f = fs.GetFile("D:\TEMP\Auswertung\Aufstellung.xls")

    I tried it and functions

  3. #3
    Join Date
    Feb 2004
    Posts
    47
    Thanks Hambakka,

    I actually wanted the file-path (e.g. "D:\TEMP\Auswertung\Aufstellung.xls") in the code.

    The path-string should be the current directory of the mdb file, that has the VBA code.

    Is there any way to get the current directory path string?

    Regards

  4. #4
    Join Date
    Jun 2004
    Posts
    96
    try currentproject.path

  5. #5
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Look up CurDir

Posting Permissions

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