- 积分
- 434
- 明经币
- 个
- 注册时间
- 2012-7-23
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
请各位帮忙解决,下面的VBA代码如何修改,才可以让选择的直线或多线长度统计到EXCEL的一个单元格内,各长度进行累加,显示长度计算式,先谢谢- Public Sub getlength() '统计长度
- Set acadApp = GetObject(, "AutoCAD.Application")
- Set Xlapp = GetObject(, "Excel.Application")
- Dim entry As AcadEntity, hjx As Variant, FType(0) As Integer, FData(0) As Variant, sjx As AcadSelectionSet, i As Long
- FType(0) = 0
- FData(0) = "Length"
- On Error Resume Next
- ThisDrawing.SelectionSets.Item("sf").Delete
- Set sjx = acadApp.ActiveDocument.SelectionSets.Add("sf")
- sjx.SelectOnScreen
- h = sjx.Count
- sjx.Select acSelectionSetAll, , , FType, FData
- With Xlapp
- k = .ActiveCell.row
- j = .ActiveCell.Column
- For Each entry In sjx
- hjx = entry.Length
- .cells(k, j) = Format(hjx / 1000, "##0.00")
- k = k + 1
- .cells(k, j).Activate
- Next entry
- End With
- sjx.Delete
- End Sub
|
|