Function xlApp() As Object
' Dim xlApp As Object ' This Line ,Not set Excel , run Excel
'Dim xlsheet As Object
' 发生错误时跳到下一个语句继续执行
On Error Resume Next
' 连接Excel应用程序
Set xlApp = GetObject(, "Excel.Application")
If Err.Number 0 Then
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Workbooks.Add
End If
' 返回当前活动的工作表
End Function
Sub labc()
Dim xlSheet
Set ArcXlsheet = xlApp.sheets(1)
ArcXlsheet.Name = "Arc"
Set CircleXlSheet = xlApp.sheets(2)
CircleXlSheet.Name = "Circle"
Set PolylineXlSheet = xlApp.sheets(3)
PolylineXlSheet.Name = "Polyline"
Set LineXlSheet = xlApp.sheets.Add
LineXlSheet.Name = "Line"
Set MTextXlSheet = xlApp.sheets.Add
MTextXlSheet.Name = "MText"
Set TextXlSheet = xlApp.sheets.Add
TextXlSheet.Name = "Text"
' Dim Set
Dim DbArc As AcadArc, DbCircle As AcadCircle
Dim DbDiametricDimension As AcadDimDiametric, DbLeader As AcadLeader
Dim DbLine As AcadLine, DbMText As AcadMText
Dim DbPolyline As AcadPolyline, DbRotatedDimension As AcadDimRotated
Dim DbSolid As AcadSolid, Ent As AcadEntity
iiArc = 1
For Each Ent In ThisDrawing.ModelSpace
Select Case Ent.ObjectName
Case "AcDbArc"
Set DbArc = Ent
ArcXlsheet.Cells(iiArc, 1) = DbArc.Center(0): ArcXlsheet.Cells(iiArc, 2) = DbArc.Center(1)
iiArc = iiArc + 1
End Select
Next Ent
ArcXlsheet.Select
End Sub