This should do it Paul
Public Sub GetExcelData()
Const sFilename As String = "C:\myTest\Volker.xls"
Dim oConn As ADODB.Connection
Dim oRS As ADODB.Recordset
Dim sFilename As String
Dim sConnect As String
Dim sSQL As String
sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sFilename & ";" & _
"Extended Properties=""Excel 8.0;HDR=Yes"""
sSQL = "SELECT * FROM [Sheet1$]"
Set oRS = New ADODB.Recordset
oRS.Open sSQL, sConnect, adOpenForwardOnly, _
adLockReadOnly, adCmdText
If Not oRS.EOF Then
ActiveSheet.Range("A1").CopyFromRecordset oRS
Else
MsgBox "No records returned.", vbCritical
End If
oRS.Close
Set oRS = Nothing
End Sub
You will need to set areference to the Microsoft ACtiveX Data Objects
Library, and change the filename to suit.
--
HTH
RP
(remove nothere from the email address if mailing direct)
"paulharvey" <
[email protected]> wrote
in message news:
[email protected]...
>
> Howdy,
>
> I need to write a macro that pulls data from a closed excel spreadsheet
> on the internet into an open spreadsheet on my hard-drive. Is this
> possible using ADO or RDS? I have tried using ADODB.Recordset with
> Provider=MS Remote, but I could not get it to work. Can anyone give me
> a sample connection string for an online excel spreadsheet? Also, which
> object library should I be using? Any suggestions?
>
> Thanks,
> Paul
>
>
> --
> paulharvey
> ------------------------------------------------------------------------
> paulharvey's Profile:
http://www.excelforum.com/member.php...o&userid=25227
> View this thread: http://www.excelforum.com/showthread...hreadid=393977
>
Bookmarks