PDA

Click to See Complete Forum and Search --> : Opening an ACAD drawing Error: MDI mode!


Wooderson78
Feb 23rd, 2004, 10:33 AM
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.


Set acad = CreateObject("Autocad.Application")
Set acad = GetObject(, "AutoCAD.Application")
acad.Visible = False

'Hide the dialogue box
Set acaDoc = acad.ActiveDocument
acaDoc.Open "C:\Projects\W7ls0116.dwg"
Set pViewport = acaDoc.ActiveViewport
pViewport.ZoomExtents
Set sset = acaDoc.SelectionSets.Add("NEWSS")
sset.Select acSelectionSetAll Set acad = CreateObject

alex_read
Feb 25th, 2004, 03:21 AM
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?

samalendu
Mar 5th, 2004, 02:31 AM
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