paulmcdonnell
Ready to Help
- Local time
- Today, 20:54
- Joined
- Apr 11, 2001
- Messages
- 167
HI guys i'm trying to use the following code to export a query to an excel spreadsheet.
Problems is I keep getting the following error:
"variable uses automation line not supported by visual basic"
for the code line:
Set objXL = New Excel.Application
Why is this, my references are correct as far as I know, I'm using access 97 and exporting to excel 2000
Hope you can help
cheers
paul
Dim rs As Recordset
Dim intMaxCol As Integer
Dim intMaxRow As Integer
Dim objXL As Excel.Application
Dim objWkb As Workbook
Dim objSht As Worksheet
Set rs = CurrentDb.OpenRecordset(rsource)
intMaxCol = rs.Fields.count
If rs.RecordCount > 0 Then
rs.MoveLast: rs.MoveFirst
intMaxRow = rs.RecordCount
Set objXL = New Excel.Application
With objXL
.Visible = True
Set objWkb = .Workbooks.Add
Set objSht = objWkb.Worksheets(1)
With objSht
.Range(.Cells(1, 1), .Cells(intMaxRow, _
intMaxCol)).CopyFromRecordset rs
End With
End With
End If
End Sub
Problems is I keep getting the following error:
"variable uses automation line not supported by visual basic"
for the code line:
Set objXL = New Excel.Application
Why is this, my references are correct as far as I know, I'm using access 97 and exporting to excel 2000
Hope you can help
cheers
paul
Dim rs As Recordset
Dim intMaxCol As Integer
Dim intMaxRow As Integer
Dim objXL As Excel.Application
Dim objWkb As Workbook
Dim objSht As Worksheet
Set rs = CurrentDb.OpenRecordset(rsource)
intMaxCol = rs.Fields.count
If rs.RecordCount > 0 Then
rs.MoveLast: rs.MoveFirst
intMaxRow = rs.RecordCount
Set objXL = New Excel.Application
With objXL
.Visible = True
Set objWkb = .Workbooks.Add
Set objSht = objWkb.Worksheets(1)
With objSht
.Range(.Cells(1, 1), .Cells(intMaxRow, _
intMaxCol)).CopyFromRecordset rs
End With
End With
End If
End Sub