Run-time error '-2145386445 (80200033)'

Run-time error '-2145386445 (80200033)'

Anonymous
適用対象外
3,461件の閲覧回数
2件の返信
メッセージ1/3

Run-time error '-2145386445 (80200033)'

Anonymous
適用対象外
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 件のいいね
3,462件の閲覧回数
2件の返信
返信 (2)
メッセージ2/3

Anonymous
適用対象外
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 件のいいね
メッセージ3/3

Anonymous
適用対象外

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 件のいいね