|
从EXCLE里读取数据实例
'============================
' 从EXCLE里读取数据实例
'============================
Option Explicit
Dim xlApp, xlFile, xlSheet,Msg
Dim iRowCount, iLoop,iLoop1,numAdd,iColCount,column2,column3,column4
Set xlApp = CreateObject ("Excel.Application")'创建访问对象xlApp
Set xlFile = xlApp.Workbooks.Open ("F:\VbScript.eg\Employees.xls")'打开文件
Set xlSheet = xlFile.Sheets("Sheet1")'设置访问文件列表
iRowCount = xlSheet.usedRange.Rows.Count
iColCount = xlSheet.usedRange.Columns.Count
For iLoop = 2 To iRowCount'取出第2行到第iRowCount行的值
For iLoop1 = 1 To iColCount'取出第一列到第iRowCount列的值
numAdd = numAdd&" "&xlSheet.Cells(iLoop,iLoop1)
Next
Msg=MsgBox("第"&iLoop&"条记录:"&numAdd,,"提示!")
numAdd=""
Next
'xlFile.Save
xlFile.Close
xlApp.Quit
Set xlSheet = Nothing
Set xlFile = Nothing
Set xlApp = Nothing |
|