I have and MS Access MDB with a form named Form1. I have an Office Spreadsheet Component 11.0 named Spreadsheet0 inserted in Form1.
On Form1_Load, I want to read records from MS Access table Table1, and write them into Spreadsheet0.
I activated the following refrences:
1) Microsoft DAO 3.6 Object Library
2) Microsoft Office Web Components 11.0
3) Microsoft ActiveX Data Objects 2.1 Libarary
I am using the following code:
Private Sub Form_Load()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim owcWbook As OWC11.Workbook
Dim owcWsheet As OWC11.Worksheet
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT * FROM Table1", dbOpenDynaset)
Set owcWbook = Me.Spreadsheet0.ActiveWorkbook
Set owcWsheet = owcWbook.ActiveSheet
When Form1 loads, I get an error which reads "Runtime Error 430, Class Does Not Support Automation....". Is this because CopyFromRecordset can only be used within Excel, or with Excel Automation? If I cannot use CopyFromRecordset, is there any other method I can use to write the Table1 records to Spreadsheet0 without looping through all of the records?