Multiple files select

Discussion in 'AutoCAD' started by Luciano Gazai, Jun 25, 2004.

  1. Hello All

    Sorry for this basic level question...but

    I need to select all .DWG files in a folder I choose
    get their file names t and save then into a variable to apply some functions
    on each.

    could anyone help me

    thanks
    Luciano Gazai
    Refrapi Engenharia Ltda
    MG - Brazil
     
    Luciano Gazai, Jun 25, 2004
    #1
  2. Luciano Gazai

    Joe Sutphin Guest

    Search this newsgroup for "directory" and I think you'll find an example
    like you're looking for.

    Joe
     
    Joe Sutphin, Jun 25, 2004
    #2
  3. I certainly didn't find anything under "directory" in this newsgroup.

    Anyhow, here's some code I am working on thich more than answers the
    question... Look specifically at the function FindFolderName. You should be
    able to do something similar with Files, as I did tieh SubFolders. This is
    DOS level stuff, not necessarily needed for the AutoCAD API.



    Public sConn As String
    Public rs As ADODB.Recordset
    Public JN As String
    Public PATH3 As String
    Public PATH4 As String

    Private Sub cboJobNo_Change()
    Me.cboSubAssy.Clear

    Dim sqlSubAssy As String
    sqlSubAssy = "SELECT tblSubAssyListing.SubAssy FROM tblSubAssyListing "
    & _
    "WHERE JobNo = " & Me.cboJobNo.Value

    rs.Open sqlSubAssy, sConn, adOpenKeyset, adLockOptimistic
    rs.MoveFirst
    Debug.Print rs.RecordCount
    Do While Not rs.EOF
    Me.cboSubAssy.AddItem rs.Fields("SubAssy")
    rs.MoveNext
    Loop

    rs.Close

    End Sub

    Private Sub cmdProcess_Click()
    Dim sqlPartNo As String
    sqlPartNo = "SELECT tblBOM.PartNo, tblBOM.SubAssy, tblBOM.PartNo,
    tblPartsListing.ManufacturedBy FROM tblPartsListing " & _
    "INNER JOIN tblBOM ON tblPartsListing.PartNo = tblBOM.PartNo
    " & _
    "WHERE (((tblBOM.JobNo) = " & Me.cboJobNo.Value & ") AND " &
    _
    "((tblBOM.SubAssy) = '" & Me.cboSubAssy.Value & "') AND " &
    _
    "((tblPartsListing.ManufacturedBy) = '" & "METRO MACHINE" &
    "'))"
    Debug.Print "sqlPartNo: " & sqlPartNo

    rs.Open sqlPartNo, sConn, adOpenKeyset, adLockOptimistic
    rs.MoveFirst
    Debug.Print rs.RecordCount

    Dim PN As String
    Dim PATH1 As String
    Dim PATH2 As String


    Do While Not rs.EOF
    PN = rs.Fields("PartNo")

    ' Determine file location per filename
    JN = Left(PN, 5)
    PATH1 = "\\deepblue\Projects\"

    If Int(Right(JN, 2)) >= 50 Then
    PATH2 = Left(JN, 3) & "50-" & Left(JN, 3) & "99\"
    Else
    PATH2 = Left(JN, 3) & "00-" & Left(JN, 3) & "49\"
    End If

    PATH3 = PATH1 & PATH2

    FindFolderName (JN)

    Dim PFile As String
    PFile = PATH4 & PN & ".dwg"
    Debug.Print PFile

    On Error GoTo skip2
    ThisDrawing.Open (PFile)
    ' ThisDrawing.sp1
    ' ThisDrawing.fpb1
    ThisDrawing.Close

    skip2:
    rs.MoveNext

    Loop


    End Sub

    Private Sub UserForm_Activate()
    sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="

    Set rs = New ADODB.Recordset

    Dim sDBPath As String
    sDBPath =
    "\\deepblue\EngineeringBOM\Data\EngineeringBOM_data.mdb;Persist Security
    Info=False"

    sConn = sConn & sDBPath

    Dim sqlJobNo As String
    sqlJobNo = "SELECT tblJob.JobNo FROM tblJOB"

    rs.Open sqlJobNo, sConn, adOpenKeyset, adLockOptimistic
    rs.MoveFirst
    Debug.Print rs.RecordCount
    Do While Not rs.EOF
    Me.cboJobNo.AddItem rs.Fields("JobNo")
    rs.MoveNext
    Loop

    rs.Close

    End Sub

    Function FindFolderName(JN As String) As String
    Dim fso As New FileSystemObject
    Dim fol As Folder
    On Error GoTo skip1
    With fso.GetFolder(PATH3)
    For Each fol In .SubFolders
    If Left(fol.Name, 5) = JN Then
    FindFolderName = fol.Name
    Exit For
    End If
    Next
    End With

    skip1:
    PATH4 = PATH3 & FindFolderName & "\Parts\"

    Set fso = Nothing

    End Function
     
    Steve Anderson, Jun 28, 2004
    #3
  4. Luciano Gazai

    MP Guest

    interesting
    are you familiar with searching via google?

    Results 1 - 10 of about 843 for group:autodesk.autocad.customization.vba
    "directory". (0.54 seconds)
     
    MP, Jun 28, 2004
    #4
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.