Hi There:
I get a run time error when i try and run the following code:
Sub GetTable()
Dim Db As Database
Dim Rs As Recordset
Dim Ws As Object
Dim i As Integer
Dim Path As String
Set Ws = Sheets("Sheet1"
Path = "c:\omnisxls\comp20031.mdb"
Ws.Activate
Range("A1"
.Activate
Selection.CurrentRegion.Select
Selection.ClearContents
Range("A1"
.Select
Set Db = Workspaces(0).OpenDatabase(Path, ReadOnly:=True)
Set Rs = Db.OpenRecordset("commissions"
For i = 0 To Rs.Fields.Count - 1
Ws.Cells(1, i + 1).Value = Rs.Fields(i).Name
Next i
Ws.Range(Ws.Cells(1, 1), Ws.Cells(1, Rs.Fields.Count)).Font.Bold = True
Ws.Range("A2"
.CopyFromRecordset Rs ' I get the error here
Sheets("Sheet1"
.Select
Range("A1"
.Select
Selection.CurrentRegion.Select
Selection.Columns.AutoFit
Range("A1"
.Select
Rs.Close
Db.Close
End Sub
The error msg says:
Method 'copy from recorset' of object 'range' failed
The data was imported into access from an excel file using the import method.
Any ideas ?
Rgds
John
I get a run time error when i try and run the following code:
Sub GetTable()
Dim Db As Database
Dim Rs As Recordset
Dim Ws As Object
Dim i As Integer
Dim Path As String
Set Ws = Sheets("Sheet1"
Path = "c:\omnisxls\comp20031.mdb"
Ws.Activate
Range("A1"
Selection.CurrentRegion.Select
Selection.ClearContents
Range("A1"
Set Db = Workspaces(0).OpenDatabase(Path, ReadOnly:=True)
Set Rs = Db.OpenRecordset("commissions"
For i = 0 To Rs.Fields.Count - 1
Ws.Cells(1, i + 1).Value = Rs.Fields(i).Name
Next i
Ws.Range(Ws.Cells(1, 1), Ws.Cells(1, Rs.Fields.Count)).Font.Bold = True
Ws.Range("A2"
Sheets("Sheet1"
Range("A1"
Selection.CurrentRegion.Select
Selection.Columns.AutoFit
Range("A1"
Rs.Close
Db.Close
End Sub
The error msg says:
Method 'copy from recorset' of object 'range' failed
The data was imported into access from an excel file using the import method.
Any ideas ?
Rgds
John