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

Run-time error '-2145386445 (80200033)'

2 REPLIES 2
Reply
Message 1 of 3
nathan.anderson
2885 Views, 2 Replies

Run-time error '-2145386445 (80200033)'

Can anyone tell my why I would be getting the attached error message when trying to run my code below? The error occurs on the second pass through the loop when the first block is supposed to be inserted.

Sub NewDrawings()

Dim i As Integer
Dim docObj As AcadDocument
Dim blockRefObj As AcadBlockReference
Dim insertionPnt(0 To 2) As Double
Dim file As String
Dim border As String
Dim bom As String

border = "S:\Templates Active\_AECL CRL\D Border.dwg"
bom = "S:\Templates Active\_AECL CRL\BOM Table.dwg"

For i = 0 To 2
file = "c:\Cable Project\cable - " & i

Set docObj = ThisDrawing.Application.Documents.Add("S:\Templates Active\acad electrical.dwt")

insertionPnt(0) = 0#: insertionPnt(1) = 0#: insertionPnt(2) = 0#
Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, border, 1#, 1#, 1#, 0)

insertionPnt(0) = 33.0172: insertionPnt(1) = 21.3085: insertionPnt(2) = 0#
Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, bom, 1#, 1#, 1#, 0)

blockRefObj.Explode 'explode the block
blockRefObj.Delete

ZoomExtents
ThisDrawing.SaveAs (file)
ThisDrawing.Close

Next i

End Sub

Any help would be great . . . I've been banging my head against the wall on this one for a while. Thanks,

Nathan
2 REPLIES 2
Message 2 of 3
rocheey
in reply to: nathan.anderson

Looks like you are trying to insert a block twice more, after you close the drawing.
You are creating a new document ("docObj ") but inserting into "ThisDrawing"


>> For i = 0 To 2
>>Set docObj = ThisDrawing.Application.Documents.Add("S:\Templates Active\acad electrical.dwt")
>>Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, bom, 1#, 1#, 1#, 0)
>>ThisDrawing.SaveAs (file)
>> ThisDrawing.Close
>>Next i
Message 3 of 3

Does the block reference you want to insert exist in your template file? I had a similar problem. The solution was to open my template dwg file, insert the block definition and then delete it, and then save over the old dwt file. This ensured that when I open a new drawing with that template, the block reference I need exists in the drawing.

 

Hope this helps!

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

Post to forums  

Autodesk Design & Make Report

”Boost