Message 1 of 9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Ok so chatgpt gave me the following code to insert a specific block from a container drawing (it has mutliple blocks in it) into AutoCAD. The problem I have with it is everytime I run it I get the following error (see the image below). Are there any suggestions for how to fix it?
Sub InsertBlockFromContainer()
Dim acadApp As AcadApplication
Dim acadDoc As AcadDocument
Dim insertPoint(0 To 2) As Double
Dim blockName As String
Dim blockPath As String
Dim insertedBlock As AcadBlockReference
' Set the block name (must match the block name in the container DWG)
blockName = "RIBPOT"
' Full path to the container drawing
blockPath = "C:\Users\Howard\AppData\Roaming\Autodesk\AutoCAD 2026\R25.1\enu\Support\Probord.dwg"
' Insertion point in current drawing
insertPoint(0) = 0: insertPoint(1) = 0: insertPoint(2) = 0
' Get AutoCAD application and active document
Set acadApp = ThisDrawing.Application
Set acadDoc = acadApp.ActiveDocument
' Insert block from external DWG
On Error Resume Next
acadDoc.SendCommand "-INSERT " & Chr(34) & blockPath & "=" & blockName & Chr(34) & " " & _
insertPoint(0) & "," & insertPoint(1) & "," & insertPoint(2) & " 1 1 0 " & vbCr
' Wait for command to complete
acadApp.Update
MsgBox "Block inserted successfully.", vbInformation
End Sub
Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Solved! Go to Solution.