Dim ConString As String
Dim strSQL As String
Dim DBPATH As String
Dim recordset As New ADODB.recordset
DBPATH = ThisWorkbook.Path & "\Data.xls"
ConString = "Provider=Microsoft.jet.oledb.4.0;" & _
"Data Source=" & DBPATH & ";" & _
"extended Properties=Excel 8.0;"
strSQL = "SELECT * FROM [Data$]"
Set recordset = New ADODB.recordset
On Error GoTo cleanup:
Call recordset.Open(strSQL, ConString, adOpenForwardOnly, adLockReadOnly,
CommandTypeEnum.adCmdText)
Call Sheets("DataDump").Range("A2").CopyFromRecordset(recordset)
Set recordset = Nothing
A place for discussion and posting about current and past VB projects, and really any other thing i want.
Thursday, October 29, 2009
VBA: Extract all data from a closed workbook
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment