VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Openning DWG > Automation error

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
400 Views, 3 Replies

Openning DWG > Automation error

I'm beginer in VBA and I'm trying to write easy program in VBA. But I have a problem with openning DWG file. I have reduced code to basic problem part:

 

Sub testing()

Dim aplikace As AcadApplication

Set aplikace = ThisDrawing.Application

aplikace.Documents.Open "c:\temp\sablona_list1.dwg", True

Set prostor = ThisDrawing.ModelSpace

End Sub

 

If it run first time, it will end by automation error. But if I press "Debug" and "F5" it will run to end. Do you know where can be mistake?

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

No idea?
Message 3 of 4
norman.yuan
in reply to: Anonymous

I suspect something is wrong with your entire VBA project.

 

With taht simple code, it should work.

 

Which version of AutoCAD are you using?

Are you sure the drawing the code is to open a good one?

 

Could you create and save a new bland drawing; then start a new VBA project and add following simplest code in a VBA module (absolutely nothing else):

 

Public Sub Test()

    Dim app As AcadApplication
    Set app = ThisDrawing.Application
    
    app.Documents.Open "C:\temp\Drawingtest1.dwg"
    
    Dim model As AcadModelSpace
    Set model = ThisDrawing.ModelSpace
    
End Sub

 and run it.

 

I have Acad2012/14/15, and of course this simple code works as it should.

 

If this works for you, then sonething may have made your VBA project "dirty" and you have to find out.

 

If this simple thing also cause the same error, then I really do not know what it is. You may want to try to repair/reinstall AutoCAD and/or AutoCAD VBA.

 

 

 

Norman Yuan

Drive CAD With Code

EESignature

Message 4 of 4
Anonymous
in reply to: norman.yuan

I have Acad2013. I'm going to try it on Monday at work. But I think I have had the same problem with new clear DWG too.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost