明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1177|回复: 2

请教高手:¥¥¥¥¥未找到主键

[复制链接]
发表于 2011-1-12 00:20:52 | 显示全部楼层 |阅读模式
Sub aa()
Dim a As Object
Dim b As Object
Dim c As Object
Dim filterType(0) As Integer, filterData(0) As Variant
Dim sset As AcadSelectionSet
Set a = CreateObject("excel.application")
Set b = a.Workbooks.Add
Set c = b.Worksheets(1)
Set sset = ThisDrawing.SelectionSets.Item("ToExcel")
filterType(0) = 0
filterData(0) = "line,circle,point"
sset.SelectOnScreen filterType, filterData
c.Range("A1") = "ObjectCount" '写入标题
c.Range("B1") = sset.Count       '写入数据
Dim Obj As AcadEntity, i As Long, varCP As Variant
   i = 2
   For Each Obj In sset
  Select Case Obj.ObjectName
    Case "AcDbLine"
    c.Range(("A" & i)) = "111" '写入对象名
       End Select
i = i + 1
Next
a.Visible = True
End Sub
发表于 2011-1-12 19:09:02 | 显示全部楼层
本帖最后由 chmenf087 于 2011-1-12 19:09 编辑

thisdrawing对象里面没有选择集
请先创建一个选择集
Set a = CreateObject("excel.application")
Set b = a.Workbooks.Add
Set c = b.Worksheets(1)

If Not IsNull(ThisDrawing.SelectionSets.Item("ToExcel")) Then
   Set sset = ThisDrawing.SelectionSets.Item("ToExcel")
   sset.Delete
End If
Set sset = ThisDrawing.SelectionSets.Add("ToExcel")
 楼主| 发表于 2011-1-13 08:17:31 | 显示全部楼层
回复 chmenf087 的帖子

多谢指点,能否给个QQ号,交个朋友
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-29 13:00 , Processed in 0.159728 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表