Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

save, close and exit many autocad session with vba code

Status
Not open for further replies.

321sh

Electrical
Oct 6, 2004
2
Presently I’m searching a way to save, close and exit many autocad sessions in VBA. I have to look at the SDI and MDI mode.



I’m sure you will know someone who could help me?



Regards,

Steve
 
Replies continue below

Recommended for you

Try the following code:

Code:
Sub CloseAcadSessions()
  Dim ACad As Object
  SessionIsOpen = True
  On Error Resume Next
  Do While SessionIsOpen
    Set ACad = GetObject(, "AutoCad.Application")
    If Err.Number <> 0 Then
    ' AutoCad is not running
      SessionIsOpen = False
    Else
      'AutoCad is running
      ACad.Quit
    End If
  Loop
  Err.Clear
  On Error GoTo 0
End Sub
 
P.S.
To save the files that are open in each AutoCAD session insert the following code before the line:
ACad.Quit

Code:
      .....
      For Each Doc In ACad.Documents
        Doc.Close SaveChanges:=True
      Next
      ACad.Quit
      .....



DARE TO IMAGINE
mala_rs_singh@rediffmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor