wwwjw 发表于 2010-5-27 11:20

读取excel文件数据并绘制直线出错

Sub excell()
Dim x, y As Variant
Dim Excel   As Excel.Application
Dim ExcelSheet   As Object
Dim ExcelWorkbook   As Object
Set ExcelWorkbook = Excel.Workbooks.Open("d:\基础数据.xls") '
Set ExcelWorkbook.Visible = True
Set ExcelSheet = ExcelWorkbook.Worksheets("基础数据") '
ExcelSheet.Activate '
x(0) = 0: x(1) = 0: x(2) = 0
For i = 1 To 50
   y(0) = ExcelSheet.cells(i, 1).Value
   y(1) = ExcelSheet.cells(i, 2).Value
   y(2) = 0
   Call ThisDrawing.ModelSpace.AddLine(x(i), y(i))
   y = x
Next
End Sub
……………………………………………………………………
我的本意是从excel文件(50行、2列)中读取数据,分别作为横纵坐标,Z坐标赋值为0,然后画线
程序不报错,也没反应,不知为何?
页: [1]
查看完整版本: 读取excel文件数据并绘制直线出错