Sub excell()* |, M4 K& Y( i x) T
Dim x, y As Variant
4 n+ A$ r. Q% m! P5 D. V9 wDim Excel As Excel.Application
1 n+ E5 H' F* O+ v, Q7 lDim ExcelSheet As Object8 X! M% F5 B! Y9 Q/ M6 }( F
Dim ExcelWorkbook As Object* ?5 s1 u! ^6 Q6 q2 `9 s
Set ExcelWorkbook = Excel.Workbooks.Open("d:\基础数据.xls") '; ?6 `/ z' i2 k9 s
Set ExcelWorkbook.Visible = True
5 I/ K4 _% t3 BSet ExcelSheet = ExcelWorkbook.Worksheets("基础数据") '
, W4 O" P- q. BExcelSheet.Activate '2 a0 l# `8 W" P/ e
x(0) = 0: x(1) = 0: x(2) = 0
p* Q4 Z0 ~2 G( ]For i = 1 To 50
- M4 U. \$ j6 H" r4 G6 ] y(0) = ExcelSheet.cells(i, 1).Value1 Z8 b4 P% o" o! t
y(1) = ExcelSheet.cells(i, 2).Value6 L4 }2 s* m1 |- D/ K
y(2) = 0
0 g8 Q" h6 ~. Y4 g Call ThisDrawing.ModelSpace.AddLine(x(i), y(i))
+ v* R8 B, s( ^, } y = x; ]4 G1 u2 o* H# U. `" a m) h
Next! E( _0 H5 ]' z+ C
End Sub1 K/ T0 n* c% P4 U% b
……………………………………………………………………, u3 ]8 F; p, p* A- k) [; M/ `
我的本意是从excel文件(50行、2列)中读取数据,分别作为横纵坐标,Z坐标赋值为0,然后画线
9 F1 D; Q: o( ~0 m" ]程序不报错,也没反应,不知为何? |