用vba编了一个,在我这边调试通过(不过没有完全达到楼主的意思,我的是把表格做成excel而非cad)- Sub aa()
- '需先:工具-引用microsoft excel 11.0 object library
- Dim d
- Dim xlsapp As Excel.Application
- Set xlsapp = CreateObject("excel.application")
- Set d = CreateObject("scripting.dictionary")
- Dim s As AcadText
- For i = 1 To ThisDrawing.ModelSpace.Count
- If ThisDrawing.ModelSpace(i - 1).ObjectName = "AcDbText" Then
- Set s = ThisDrawing.ModelSpace(i - 1)
- d(s.TextString) = d(s.TextString) + 1
- End If
- Next
- xlsapp.Workbooks.Open ThisDrawing.Path & "\book1.xls"
- xlsapp.Workbooks(1).Sheets(1).[a1].Resize(d.Count, 1) = xlsapp.WorksheetFunction.Transpose(d.keys)
- xlsapp.Workbooks(1).Sheets(1).[b1].Resize(d.Count, 1) = xlsapp.WorksheetFunction.Transpose(d.items)
- xlsapp.Workbooks(1).Save
- xlsapp.Quit
-
- End Sub
|