Results 1 to 2 of 2

Thread: Excel

  1. #1
    Guest
    Is it possible to open up an excel spreadsheet and populate it with the contents of a recordset?

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    Code:
    '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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width