How to Export an Excel Sheet into an Access table.

This sample shows How to Export an Excel Sheet into an Access table.

For the sample code to run you will need to do the following things:
1. Add a Reference to Microsoft DAO 3.5(VB5) or 3.51(VB6) Object Library.
2. 1 Command Button.
3. Make sure you have the correct path to the Excel sheet. Remeber to change the OpenDatabase and Execute lines to reflect your Excel sheet and Database.

Option Explicit
Dim db As Database

'This sample shows How to Export an Excel Sheet into an Access table.

Private Sub Command1_Click()
'This procedure uses a Select into statement to create a new table
'Make sure to change the path to the location of your excel sheet and to you database.
Set db = OpenDatabase("d:\Authors.xls", False, False, "Excel 8.0;")
db.Execute "Select * into XlAuthors in 'd:\db1.mdb' from [Authors$]"
MsgBox "done"
End Sub


[Home]   [Back to the top]


Hosted by www.Geocities.ws

1