markc0826 发表于 2012-9-12 12:10
看来您程式是写在excel中然後呼叫AutoCAD去抓资讯,这样子您的loop回圈应该写在Excel的运行上才有办法连续抓 ...
没有用数组的方式可以量取多个距离,但是需要每次都按“确定”,是否可以在选择结束以后再按键盘上的回车键结束呢?(结束本过程)- Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Long
- Public acadApp As Object
- Public acadDoc As Object
- Public ssetObj As AcadSelectionSet
- Public ssobj As AcadSelectionSet
- Public Xlapp As Object
- Public WT As Object
- Private Sub Command4_Click() '测量长度
- Dim acadDoc As AcadDocument
- Set acadApp = GetObject(, "AutoCAD.Application")
- If Err Then
- Err.Clear
- Set acadApp = CreateObject("AutoCAD.Application")
- If Err Then End
- End If
- acadApp.Visible = True
- Set acadDoc = acadApp.ActiveDocument
- Set Xlapp = GetObject(, "Excel.Application")
- Set WT = Xlapp.ActiveWorkbook.ActiveSheet
- AppActivate "AUTOCAD"
- Dim PT1 As Variant
- Dim Dis As Double
- Dim YoN
- YoN = vbYes
- Do Until YoN = vbNo
- PT1 = acadDoc.Utility.GetPoint(, "1st Point")
- Dis = Format(acadDoc.Utility.GetDistance(PT1, "2nd Point") / 1000, "##0.00")
- Xlapp.ActiveCell = Dis
- Xlapp.ActiveCell.Offset(1, 0).Select
- YoN = MsgBox("已经测量,是否继续?", vbYesNo)
- Loop
- End Sub
请帮助修改一下,达到以上效果,先谢谢 |