Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    listing file in a specific dir (2000 sr-1)

    Possible to list in a userform the file in c:my_dir
    Note:Possible a sub dir in my_dir

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: listing file in a specific dir (2000 sr-1)

    Suppose I have a user form with a textbox called tbxFolder and a listboc called lbxFiles:

    <pre>Sub GetFiles()
    Dim sFile As String
    Dim sFiles() As String
    Dim lCount As Long
    Dim lFileCount As Long
    ReDim sFiles(1)
    sFile = tbxFolder
    If Right(sFile, 1) <> Application.PathSeparator Then
    sFile = sFile & Application.PathSeparator
    End If
    If Dir(sFile, vbDirectory) = "" Then
    lbxFiles.Clear
    Exit Sub
    End If
    sFile = Dir(sFile & "*.xls")
    While sFile <> ""
    lCount = lCount + 1
    ReDim Preserve sFiles(lCount)
    sFiles(lCount) = sFile
    sFile = Dir()
    Wend
    lFileCount = lCount
    lbxFiles.Clear
    mbDisableEvents = True
    For lCount = 1 To lFileCount
    lbxFiles.AddItem sFiles(lCount)
    Next

    End Sub
    </pre>

    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: listing file in a specific dir (2000 sr-1)

    NICE and good!
    Tks.

Posting Permissions

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