1.可能中文版与英文版的出错代码有所不同。
2.你的程序中没有On Error Resume Next语句。
3.要保存所需要的文件存在于指定的目录。
- Sub InsBlk()
- Dim AcadApp As AcadApplication
- Set AcadApp = ThisDrawing.Application
- Dim insertpt(0 To 2) As Double
- insertpt(0) = 0#: insertpt(1) = 0#: insertpt(2) = 0#
- Dim blockrefobj As AcadBlockReference
- On Error Resume Next
- Set blockrefobj = AcadApp.ActiveDocument.ModelSpace.InsertBlock(insertpt, "abc", 1#, 1#, 1#, 0#)
- If Err.Number = -2145386445 Or Err.Number = -2147418113 Then
- Set blockrefobj = AcadApp.ActiveDocument.ModelSpace.InsertBlock(insertpt, "d:\abc.dwg", 1#, 1#, 1#, 0#)
- End If
-
- End Sub
|