¤ Hi,
¤ How to import Excel sheet into Access database programatically?
Couple of different ways to do this. The following example assumes that table does not already exist
in the Access database (creates a new table):
Public Sub ImportExcelToAccess()
Dim AccessConn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"
& _
"Data Source=e:\My Documents\db1.mdb")
Try
AccessConn.Open()
Dim AccessCommand As New System.Data.OleDb.OleDbCommand("SELECT * INTO [tblSheet1] FROM
[Excel 8.0;DATABASE=e:\My Documents\Book10.xls;HDR=NO;IMEX=1].[Sheet1$]", AccessConn)
AccessCommand.ExecuteNonQuery()
AccessConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
AccessConn.Close()
End Try
End Sub
Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)