great_kevin 发表于 2010-5-27 11:34:00

[求助]读取excel文件数据并绘制一系列直线出错,求解

<p>Sub excell()<br/>Dim x, y As Variant<br/>Dim i As Integer<br/>Dim Excel&nbsp;&nbsp; As Excel.Application<br/>Dim ExcelSheet&nbsp;&nbsp; As Object<br/>Dim ExcelWorkbook&nbsp;&nbsp; As Object<br/>On Error Resume Next<br/>&nbsp; Set Excel = GetObject(, "Excel.Application")<br/>If Err &lt;&gt; 0 Then<br/>&nbsp;&nbsp;&nbsp; Set Excel = CreateObject("Excel.Application")<br/>End If<br/>Set ExcelWorkbook = Excel.Workbooks.Open("d:\基础数据.xls")<br/>Set ExcelWorkbook.Visible = True<br/>Set ExcelSheet = ExcelWorkbook.Worksheets("基础数据")<br/>ExcelSheet.Activate<br/>x(0) = 0: x(1) = 0: x(2) = 0<br/>For i = 1 To 50<br/>&nbsp;&nbsp; y(0) = ExcelSheet.cells(i, 1).Value<br/>&nbsp;&nbsp; y(1) = ExcelSheet.cells(i, 2).Value<br/>&nbsp;&nbsp; y(2) = 0<br/>&nbsp;&nbsp; Call ThisDrawing.ModelSpace.AddLine(x, y)<br/>&nbsp;&nbsp; x = y<br/>&nbsp;&nbsp; Next<br/>End Sub</p><p>……………………………………………………………………<br/><font size="4">我的本意是从excel文件(50行、2列)中读取数据,分别作为横纵坐标,Z坐标赋值为0,然后画线<br/>程序不报错,也没反应,不知为何?</font></p><p><br/></p>
页: [1]
查看完整版本: [求助]读取excel文件数据并绘制一系列直线出错,求解