[求助]请问如何将数据发送到一打开的EXCEL表格?
<font class="topic" size="3">选择一封闭的多段线,然后将其面积、长度数据分别发送到一打开的EXCEL表格的指定单元格(或活动单元格)</font> 本帖最后由 作者 于 2007-5-27 1:05:22 编辑 <br /><br /> <p>我编了这几句,哪位朋友能帮我优化一下吗?</p><p>Sub CX()</p><p> Dim uselect As AcadSelectionSet<br/> Dim mj As String, zc As String<br/> Dim Excelapplication As Excel.Application<br/> Dim Excelsheet As worksheet<br/> <br/> <br/> With ThisDrawing<br/> On Error Resume Next<br/> .SelectionSets("currentselection").Delete<br/> <br/> Set uselect = .SelectionSets.Add("currentselection")<br/> <br/> uselect.SelectOnScreen<br/> For Each objselect In uselect<br/> mj = objselect.Area<br/> zc = objselect.Length<br/> Next<br/> ' MsgBox "面积= " & mj & " !", vbInformation '信息框<br/> End With<br/> <br/> On Error Resume Next<br/> Set Excelapplication = New Excel.Application<br/> Excelapplication.Visible = True 'False<br/> Excelapplication.workbooks.Add<br/> Set Excelsheet = Excelapplication.activeworkbook.sheets("sheet1")<br/> Excelsheet.cells(1, 1).Value = "面积"<br/> Excelsheet.cells(1, 2).Value = "周长"<br/> Excelsheet.cells(2, 1).Value = mj<br/> Excelsheet.cells(2, 2).Value = zc<br/>End Sub</p><p></p>
页:
[1]