A follow up to this post. Actually came upon a need to create an XLS format without having MS Office installed. In post #2 above a DAO example exists. Here is a similar example using ADO:
Apologize if any typos. And found one. Had a comma after the field name in Create Table clause. Removed it.Code:Sub Main() Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Set cn = New ADODB.Connection cn.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0; data source=c:\test.xls; Extended Properties=""Excel 8.0;HDR=YES""" cn.Open cn.Execute "Create Table Table1(field1 VARCHAR(255))" Set rs = New ADODB.RecordSet rs.Open "[Table1$]", cn, adOpenDynamic, adLockOptimistic, adCmdTable rs.AddNew rs.Fields(0).Value = "hello!" rs.Update rs.Close: cn.Close Set rs = Nothing Set cn = Nothing End Sub




Reply With Quote
