Hi to all
My name is Luigi
I would like to excel by pasting a block in a drawing autocad.
Using the manual ActiveX and VBA for autocad (200 I found this code, but it returns an error dialog at the end
I use Excel 2012 (32bit) - Autocad Electrical 2015 (64bit) - Windows 7 (64bit)
AutoCAD 2015 Type Library is included in the references
I should have the opportunity 'to choose the block via a combobox, and paste the block in the current drawing
I enclose the code that tells me error
Module
Code:
Sub Ch10_AttachingExternalReference()
On Error GoTo ERRORHANDLER
Dim InsertPoint(0 To 2) As Double
Dim insertedBlock As AcadExternalReference
Dim tempBlock As AcadBlock
Dim msg As String, PathName As String
' Define external reference to be inserted
InsertPoint(0) = 1
InsertPoint(1) = 1
InsertPoint(2) = 0
PathName = "C:/Autodesk/Smoke/E20.dwg"
' Display current Block information for this drawing
GoSub ListBlocks
' Add the external reference to the drawing
Set insertedBlock = ThisDrawing.ModelSpace.AttachExternalReference(PathName, "XREF_IMAGE", InsertPoint, 1, 1, 1, 0, False)
ZoomAll
' Display new Block information for this drawing
GoSub ListBlocks
Exit Sub
ListBlocks:
msg = vbCrLf ' Reset message
For Each tempBlock In ThisDrawing.Blocks
msg = msg & tempBlock.Name & vbCrLf
Next
MsgBox "The current blocks in this drawing are: " & msg
Return
ERRORHANDLER:
MsgBox Err.Description
End Sub
Button un form
Code:
Private Sub CommandButton2_Click()
Ch10_AttachingExternalReference
End Sub
Error
excel.PNG
necessary object
Can you help me solve this problem?
thanks