Run-time error '-2145386445 (80200033)'

Run-time error '-2145386445 (80200033)'

Anonymous
Not applicable
3,471 Views
2 Replies
Message 1 of 3

Run-time error '-2145386445 (80200033)'

Anonymous
Not applicable
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
0 Likes
3,472 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
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
0 Likes
Message 3 of 3

Anonymous
Not applicable

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!

0 Likes