Results 1 to 3 of 3

Thread: Opening an ACAD drawing Error: MDI mode!

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Posts
    8

    Angry Opening an ACAD drawing Error: MDI mode!

    I can't seem to open an Autocad drawing in VBA. i keep getting a Collection not available in MDI mode error. Use documents. Here's the code I'm trying to run.

    VB Code:
    1. Set acad = CreateObject("Autocad.Application")
    2.     Set acad = GetObject(, "AutoCAD.Application")
    3.     acad.Visible = False
    4.    
    5. 'Hide the dialogue box
    6.     Set acaDoc = acad.ActiveDocument
    7.     acaDoc.Open "C:\Projects\W7ls0116.dwg"
    8.     Set pViewport = acaDoc.ActiveViewport
    9.     pViewport.ZoomExtents
    10.     Set sset = acaDoc.SelectionSets.Add("NEWSS")
    11.     sset.Select acSelectionSetAll Set acad = CreateObject

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    You should only need the 1st line rather than the top 2 - try commenting out the 2nd line to start with.

    What line does this fall over on? & what is the bottom line there meant to do please?

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3
    New Member
    Join Date
    Mar 2004
    Location
    India
    Posts
    1

    Thumbs up

    Hope this will work...

    Code:
    --------------------------------------------------------------------
    Dim acadApp As AcadApplication

    Set acadApp = GetObject(, "AutoCAD.Application")
    If Err Then
    Err.Clear
    'Open AutoCAD app if not already open
    Set acadApp = CreateObject("AutoCAD.Application")
    acadApp.Visible = True
    If Err Then
    MsgBox Err.Description
    Exit Sub
    End If
    End If
    Regards,
    Sam

Posting Permissions

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



Click Here to Expand Forum to Full Width