Close specific file

Discussion in 'AutoCAD' started by Guest, Nov 18, 2004.

  1. Guest

    Guest Guest

    I have written the following codes to open some files,now I need to make
    another module that can close them ,
    how should I do this? what ever I tried I couldn't make it,can anyone help
    me with that?

    Thanks in advance.
    Afshin.


    Sub open_all_details()

    Dim drawingfile As AcadDocument
    Dim directory(0 To 3) As String
    Dim i As Integer
    i = 0

    directory(0) = "C:\Documents and
    Settings\afshin.ST-1.000\Desktop\D\A10-GLOBAL.DWG"
    directory(1) = "C:\Documents and Settings\afshin.ST-1.000\Desktop\D\A20-ROOF
    & FLOOR.dwg"
    directory(2) = "C:\Documents and
    Settings\afshin.ST-1.000\Desktop\D\A30-CONNECTION.dwg"
    directory(3) = "C:\Documents and
    Settings\afshin.ST-1.000\Desktop\D\A40-FOOTING.dwg"

    For i = 0 To 3
    If Dir(directory(i)) <> "" Then
    Set drawingfile = Application.Documents.Open(directory(i))
    Else
    MsgBox "File " & directory(i) & " does not exist."
    End If
    Next


    End Sub
     
    Guest, Nov 18, 2004
    #1
  2. Guest

    Michel Guest

    Have you tried iterating the documents collection? You can check each name to determine if it must be closed.
    Michel


    Sub CloseDoc(strDoc As String)
    Dim objDoc As AcadDocument

    For Each objDoc In Application.Documents
    If objDoc.FullName = strDoc Then
    objDoc.Close
    Exit Sub
    End If
    Next

    End Sub
     
    Michel, Nov 18, 2004
    #2
  3. Guest

    Guest Guest

    Thanks Michel,
     
    Guest, Nov 25, 2004
    #3
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.