README.md
December 5, 2022 ยท View on GitHub
Description
An alternative method of reading an MS Excel Spreadsheet.
More Info
You must supply the full path and file name of the Excel Sheet you wish to read.
It returns the Specified Sheets' data in an ADO recordset.
| Submitted On | |
| By | BigP |
| Level | Advanced |
| User Rating | 4.6 (51 globes from 11 users) |
| Compatibility | VB 6.0 |
| Category | Databases/ Data Access/ DAO/ ADO |
| World | Visual Basic |
| Archive File |
Source Code
Dim cn As ADODB.Connection
Dim rsADO As New ADODB.Recordset
Dim strSQL As String
Dim strPath as string
Set cn = New ADODB.Connection
strPath = '[ADD FULL PATH AND FILE NAME]
With cn
.Provider = "MSDASQL"
.ConnectionString = "Driver={Microsoft Excel Driver (*.xls)};" & _
"DBQ=" & strPath & " ; ReadOnly=false;MaxScanRows= 0;"
.Open
End With
' Specify Sheet Name and Cell Range
strSQL = "SELECT * FROM [Sheet1$A1:Z10]"
rsADO.Open strSQL, cn
Do while not rs.EOF
' Add code here to work with recordset
rsADO.MoveNext
Loop
Set cn = Nothing
Set rsADO = Nothing