- 积分
- 1222
- 明经币
- 个
- 注册时间
- 2003-7-6
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2003-8-15 00:44:00
|
显示全部楼层
别人写的一段程序,看看
Sub ADO_EXCEL_TEST()
On Error Resume Next
Dim adoConnection As New ADODB.Connection
Dim adoRecordset As New ADODB.Recordset
Dim SPoint(0 To 2) As Double
Dim EPoint(0 To 2) As Double
Dim i As Integer
adoConnection.Open "rovider=Microsoft.Jet.OLEDB.4.0ersist Security Info=False;Data Source=d:\book2.xls;Extended Properties='Excel 8.0;HDR=No'"
'Microsoft.Jet.OLEDB.4.0 方式,(建议)
' HDR=No HDR参数设置是否强制将第一行单元格作为字段名称 YESà将第一行单元格作为字段名称;NOà忽略
adoRecordset.Open "select * from [sheet1$]", adoConnection, adOpenKeyset, adLockOptimistic '读取SHEET1的数据
For i = 0 To 2
SPoint(i) = adoRecordset.Fields(i).Value
Next
adoRecordset.MoveNext
For i = 0 To 2
EPoint(i) = adoRecordset.Fields(i).Value
Next
ThisDrawing.ModelSpace.AddLine SPoint, EPoint
End Sub |
|