PDA

Click to See Complete Forum and Search --> : Excel


Jan 17th, 2001, 05:45 AM
Is it possible to open up an excel spreadsheet and populate it with the contents of a recordset?

Clunietp
Jan 17th, 2001, 09:51 AM
'uses ado 2.1 or higher

Dim cn As New Connection
Dim rs As New Recordset

cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Test.xls;Extended Properties=Excel 8.0;"

'excel sheet name here
'must enclose in brackets, sheet name followed by a dollar sign
rs.Open "Select * from [Sheet1$]", cn, adOpenKeyset, adLockOptimistic



then you can do rs.addnew to add your records to the sheet