Importing Excel Spreadsheet into an Access 2000 Table using VB 
Author Message
 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?

Thanks

J



Sat, 24 Sep 2005 04:10:08 GMT  
 Importing Excel Spreadsheet into an Access 2000 Table using VB
Hi,

You could try to use automation to do that. Check an example how to transfer
data from Access to Excel. It could give you some ideas

http://support.microsoft.com/default.aspx?scid=kb;en-us;210288

--
Val Mazur
Microsoft MVP


Quote:
> 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?

> Thanks

> J



Sat, 24 Sep 2005 20:23:07 GMT  
 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)



Sat, 24 Sep 2005 22:52:18 GMT  
 Importing Excel Spreadsheet into an Access 2000 Table using VB
This is good, but what if the location of the spreadsheet is not known?


Quote:

> 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;" & _

- Show quoted text -

Quote:
>    "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)



Sun, 25 Sep 2005 20:48:48 GMT  
 Importing Excel Spreadsheet into an Access 2000 Table using VB

This is good, but what if the location of the spreadsheet is not known?

You can build your connection string based upon the location supplied from the Common Dialog
control. Assuming you know how to use the Command Dialog control and have assigned the value to a
variable (strExcelWorkbookPath in this example):

sqlString = "SELECT * INTO [tblExcelNew] FROM [Excel 8.0;DATABASE=" & strExcelWorkbookPath &
";HDR=NO].[Sheet1$]"


Microsoft MVP (Visual Basic)



Mon, 26 Sep 2005 01:11:17 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Importing an Access 2000 table into another Access 2000 database with VB Code

2. Importing Excel SpreadSheet(w/TABS) into Access Table

3. linking an excel spreadsheet to an access table using vb

4. Import and Excel Spreadsheet to 4 Tables

5. Import an Excel Spreadsheet and Update 4 related tables

6. Export tables to Excel Spreadsheet using VB

7. Access table to Excel Spreadsheet in VB 6

8. linking a excel spreadsheet to an access table through vb

9. Help!: Import Access Table into Excel Using VB3

10. read excel file in access 2000 lire fichier excel dans access 2000

11. importing Excel Spreadsheets using code?

12. Import excel spreadsheet to claendar using a macro

 

 
Powered by phpBB® Forum Software