
Importing Excel Spreadsheet into an Access 2000 Table using VB
Hi,
Is there an article on how to Import Excel data into an Access 2000
Table using VB 6.0.
Preferably using a common dialog?
You can use the CommonDialog to get the file name and ADO to perform the import:
Sub ImportExcelToAccess()
Dim cnn As New ADODB.Connection
Dim sqlString As String
cnn.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=D:\My Documents\Accessdb.mdb;" & _
"Jet OLEDB:Engine Type=4"
'Assumes Access table does not already exist
sqlString = "SELECT * INTO [tblExcelNew] FROM [Excel 8.0;DATABASE=D:\My
Documents\Test.xls;HDR=NO].[Sheet1$]"
cnn.Execute sqlString
cnn.Close
Set cnn = Nothing
End Sub
If you need to import into an existing Access table post a follow-up.
Microsoft MVP (Visual Basic)