|
Sub a() '连接EXCEL——标准代码**************************** Dim xlApp As Excel.Application Dim xlbook As Excel.Workbook Dim xlSheet As Excel.Worksheet On Error Resume Next Set xlApp = GetObject(, "excel.application") If Err 0 Then Err.Clear Set xlApp = CreateObject("excel.application") If Err 0 Then MsgBox "无法启动excel" Exit Sub End If End If If ActiveWorkbook.Sheets.Count = 0 Then xlbook = xlApp.Workbooks.Add Set xlbook = xlApp.ActiveWorkbook Set xlSheet = xlbook.ActiveSheet xlApp.Visible = True If Err 0 Then Err.Clear '标准代码结束*****************************************Dim retCoord() As DoubleDim a As AcadLWPolylineDim i As IntegerDim j As IntegerDim l As Integeri = 0ThisDrawing.Utility.GetEntity a, "Select an object" retCoord() = a.CoordinatesOn Error GoTo eDo While CBool(retCoord(i)) Falsej = ActiveCell.Row '这个无法返回激活单元格地址l = ActiveCell.ColumnxlSheet.Cells(j + i / 2, l).Value = retCoord(i) xlSheet.Cells(j + i / 2, l + 1).Value = retCoord(i + 1)i = i + 2Loope: Exit Subj = 0 l = 0End Sub 以上是一个将cad中多段线点坐标导入excel中去的代码,在cad中运行该宏,电脑提示“用户定义类型未定义”(红色部分),这是怎么回事??哪位大侠能告诉我?? |
|