Include the names of dwg's in an array.

Discussion in 'AutoCAD' started by Oscar Barbero Pinacho, May 24, 2004.

  1. I have problems to make an array with the dwg files that are in a directory
    that I choose when I run my app. I want to use this array to include
    information about the layouts that containes the file.

    How can I do this




    Thanks,
    Oscar Barbero Pinacho
     
    Oscar Barbero Pinacho, May 24, 2004
    #1
  2. Oscar Barbero Pinacho

    Ben Rand Guest

    Oscar,

    I got this from a VB newsgroup somewhere, but I neglected to make a note of
    who/where (my apologies to the author whoever you are). It returns an array
    of file names from the folder you specify, with whatever extension you
    provide.

    Function GetFileList(strPath As String, strExt As String) As Variant
    'Be sure strPath includes a "\" at the end
    'Be sure strExt is in the format "*.dwg" (or whatever extension you're
    after)
    On Error Resume Next
    Dim FName As String
    Dim FList() As Variant
    Dim cnt As Integer
    Dim I As Integer

    FName = Dir(strPath & strExt)
    If FName = "" Then
    ' MsgBox "Can't find " & strPath & " folder or folder contains no " &
    strExt & " files"
    GetFileList = Empty
    Exit Function
    End If

    cnt = 1
    Do While FName <> ""
    FName = Dir
    cnt = cnt + 1
    Loop
    ReDim FList(0 To cnt - 2)
    FList(0) = UCase$(Dir(strPath & strExt))
    For I = 1 To cnt - 2
    FList(I) = UCase$(Dir)
    Next I

    GetFileList = FList
    End Function

    Ben Rand
    CAD Manager
    CEntry Constructors & Engineers
     
    Ben Rand, May 24, 2004
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.